Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a variable, vYear=GetFieldSelections(Year) and a set expression using this variable -
Count({<Year={"$(=$(vYear))"}>}Distinct [Groups Key]).
The above set expression works when a single value is selected in the Year filter, but when I select multiple values in the filter the set expression returns null. Can anyone please guide me how to fix this expression ?
Appreciate your help !
Thanks,
Deepika
If you want the selections in the field Year to be applied to the expression then you can use this expression:
Count(Distinct [Groups Key])
There's no need for set analysis because the selections you make are the same that you want to use for calculating the expression.
Hi Gysbert,
Thanks for the response.
The chart where I am using the set expression uses a fact table which is linked to master calendar, but the Year filter is not referencing the Master calendar, but a different table not linked to the master calendar. This is the reason for the set expression.
Deepika
That's not possible. You're using the field 'Year' in both the getfieldselections function and the count expression. You are using the same field 'Year' in both cases. So you get exactly the same selections.
There can only be one field 'Year' in the data model. If two or more tables have that same field 'Year' then those tables are linked. That's the way Qlikview works.
Sorry, the set expression should have been like this - Count({<MC_Year={"$(=$(vYear))"}>}Distinct [Groups Key]).
Can you please post a sample application.
Hi, try this:
vYear=CONCAT(DISTINCT Year,',')
Count({<Year={$(vYear)}>}Distinct [Groups Key])
Regards!!
Ok, then try this one: Count({<MC_Year=$::Year>}Distinct [Groups Key])
Hi
This drove me nuts too; I have implemented something similar in a dashboard I worked on recently
It's a two step approach as Manuel has indicated.
First, populate the variable and format it as per below (take note of ' and "); please note I had to assign * value for my expression to work when no Year was selected:
vYear=if(isnull(GetFieldSelections(Year)), '*', Replace(Replace(GetFieldSelections(Year),' ',''),',','","'))
Try use the following in your set expression:
=count({<Year = {"$(vYear)"}>} Distinct [Groups Key])
Hope it helps
Lorenzo
Hi Lorenzo, with concat function you don't need to use *.
Regards!