Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Mur
Contributor II
Contributor II

Default filter

Hello,

I have used filter panes in one of my sheet in qliksense. One of the filters is to select Gender. The filed name in my data source is Gender and it has rows for F (as female) and M( as male). Previously, I had this expression behind my filter 
if(Gender='F','Female',if(Gender='M','Male')). it works fine.

Now user wants that every time they open the sheet it filters out the report automatically or by default to Male. and later, if they need then change and select the Female option in the filter.

I have set this variable in the main section in data load editor SET vDefaultFilter='Male', and modify the expression like this: if(Gender='F','Female','$(vDefaultFilter)')

the expression says ok but it does not filter data by default to Male. I still need to go and select Male option.

could someone help please?

Thank you!

Labels (3)
1 Solution

Accepted Solutions
here2h3lp
Partner - Contributor III
Partner - Contributor III

if you replace in your script by the correct value (if(Gender='F','Female',if(Gender='M','Male')) as Gender)

then you can create an action

Action : select values in a field

Field : Gender

Values : Male

 

 

View solution in original post

9 Replies
pravinboniface
Creator II
Creator II

@Mur Try using a Sheet action as follows:

pravinboniface_0-1713235737637.png

 

Mur
Contributor II
Contributor II
Author

Thank you @pravinboniface  for the response. I tried using sheet action as you suggested but it still won't select the option I want by default. Here are the ways I tried but both ways did not work. I am new to Qliksense so maybe I am missing a step. Please let me know how I can resolve this?

Mur_0-1713276226316.pngMur_1-1713276249017.png

 

 

here2h3lp
Partner - Contributor III
Partner - Contributor III

You should change the value of Gender directly on your script to avoid having to replace F by female in every expression.

That way you can have a new field that has the value female or male and work directly with that field.

Mur
Contributor II
Contributor II
Author

Thanks for the response! So you mean if I did not have If condition in my expression, the default filter would work! I dont think the problem is in my filed name being F for Femal or M for Male. Let's say I don't add the If condition, now my filter pane shows like this:

Mur_0-1713285296354.png

And I set a variable like this:
SET vDefaultFilter= 'M'


what can I do to make the sheet select M by default whenever user opens the sheet?

 

Thanks,

here2h3lp
Partner - Contributor III
Partner - Contributor III

if you replace in your script by the correct value (if(Gender='F','Female',if(Gender='M','Male')) as Gender)

then you can create an action

Action : select values in a field

Field : Gender

Values : Male

 

 

Mur
Contributor II
Contributor II
Author

Thank you so much. It worked. I really appreciate your help.

Mur
Contributor II
Contributor II
Author

similar to my first question, I am applying default filter to my sheet but this time I have several filters. so I wanted to apply actions to my sheet again.

First filter:

Action : select values in a field

Filed name: FY

The value I want to show is the current year, so I wrote this formula in the value section:

FY= '$(=Year(Today()))'

 

Second filter:

Action : select values in a field

Field: Period

The value I want to show is the pervious month, so I wrote this formula in the value section:

Period='$(=MonthStart(Today(), -1))'

other filters:

Action : select values in a field
Field: ACC_Type
Value: A

Action : select values in a field
Filed: Level
Value: Level 1

when I exit and come back to the sheet, by default ACC_Type and Level filter the sheet and select A and 1, but FY and Period won't be applied.

Just to try, I removed the formulas and instead just put 2024 as value for FY and 3 as value for Period, and it worked. It filters the table by default when I open the sheet, However, that is not what users wants. They want a dynamic default filter.

 

let me know how to resolve this.

 

thank you for your help in advance!!

 

 

 

 

Mur
Contributor II
Contributor II
Author

Anyone any idea please?

joshsiddle8
Contributor III
Contributor III

If you update your script with the correct value assignment (if(Gender='F','Female',if(Gender='M','Male')) as Gender), you'll be able to perform the following action:

Action: Select values in a field

Field: Gender

Values: Male

So yeah someone already given you similar answer like this.