Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Talk to Experts, a LIVE Q&A Webinar. Bring your Qlik Sense Business questions on Aug. 4th. Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Contributor II
Contributor II

One filter pane for two columns via set analysis

Hi everyone! 

I'm currently trying to apply one filter pane to two columns of a pivot table with similar date values. 

Here is what I have come up with so far: 

 

count(
{1<[Field1.autoCalendar.YearMonth] = {"$(=GetFieldSelections([Field2.autoCalendar.YearMonth]))"}>}
[Field1])

So, if I set a filter on Field two, it will automatically count the filter chosen values from Field1.

Now, the problem I have is that if I try to choose more than one value on the filter pane, GetFieldSelections returns a string like "value1, value2", and obviously my functions crashes down. 

I understand what causes the problem, but can't think of any way around. It would make sense to replace the "=" with "in" to make a python-like structure, but qlik sense doesn't have the in-operator. 

Could you please give me some ideas? 

1 Solution

Accepted Solutions
Highlighted
Partner
Partner

Re: One filter pane for two columns via set analysis

Hi!

You have something like that "in" you are looking for. In a set expression you can use

{<Country = {'Spain', 'F*'}>}

Which means Country = 'Spain' or Country like 'F*'. You need a list of values separated by a comma. Said so and following your approach to the problem, you can use

Sum({<Date1 = {'$(=GetFieldSelections(Date2, chr(39) & ',' & chr(39)))'}>} Amount)

BUT the following expression is simpler and does exacly the same 

Sum({<Date1 = $::Date2>} Amount)

The set modifier of the above expression means Date1 = "What is selected in the field Date2 in the state $" 

Finally, note that if you select nothing both expressions above will rise a 0.

Regards,

Jaime.

View solution in original post

2 Replies
Highlighted
Partner
Partner

Re: One filter pane for two columns via set analysis

Hi!

You have something like that "in" you are looking for. In a set expression you can use

{<Country = {'Spain', 'F*'}>}

Which means Country = 'Spain' or Country like 'F*'. You need a list of values separated by a comma. Said so and following your approach to the problem, you can use

Sum({<Date1 = {'$(=GetFieldSelections(Date2, chr(39) & ',' & chr(39)))'}>} Amount)

BUT the following expression is simpler and does exacly the same 

Sum({<Date1 = $::Date2>} Amount)

The set modifier of the above expression means Date1 = "What is selected in the field Date2 in the state $" 

Finally, note that if you select nothing both expressions above will rise a 0.

Regards,

Jaime.

View solution in original post

Highlighted
Contributor II
Contributor II

Re: One filter pane for two columns via set analysis

Hi, Jaibau

To be honest, I coudn't get the shorter one going, but you first suggestion works just fine! I was almost there 😃

Situations when nothing is selected can be easily avoided with an if statement. 

Thank you so much!