Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm trying to find the correct syntax to use with GetFieldSelections.
My code is below.
If(GetFieldSelections(DayFlag)='AM Only', Count({<DayFlag={'AM Only'}>}Distinct OR_Date),
If(GetFieldSelections(DayFlag)='PM Only', Count({<DayFlag={'PM Only'}>}Distinct OR_Date),
If(GetFieldSelections(DayFlag)='All Day', Count({<DayFlag={'All Day'}>}Distinct OR_Date),
If(GetFieldSelections(DayFlag)='AM Only' and GetFieldSelections(DayFlag)='All Day', Count({<DayFlag={'AM Only'}>}Distinct OR_Date)+Count({<DayFlag={'All Day'}>}Distinct OR_Date)))))
What I want to find is if the DayFlag chosen is 'AM Only' AND 'All Day' then do this...
That is fine. But it seems that your data model is connected since you are using the same flag field in set analysis. If you select a value from your flag field, qlik associative engine itself would filter the data accordingly. I am not sure if am missing anything here. Try using the expression I suggested and keep selecting different flag values - you should get what you need. Otherwise, to answer your very question try like:
If(GetFieldSelections(DayFlag)='AM Only, All Day', Count({<DayFlag={'AM Only', 'All Day'}>}Distinct OR_Date)
If you select two or more values, getfieldselections() would return them separated by a comma and a space. Also note, you don't need two counts for two values, you can pass multiple values in one set analysis like shown above.
Why do you need separate expression for all the flag selections, especially when you are writing to calculate the same value as would have been in default expression without set analysis?
Did you try:
Count(Distinct OR_Date)
?
Because the same OR_Date might have an AM Only and a PM Only or an All Day flag.
That is fine. But it seems that your data model is connected since you are using the same flag field in set analysis. If you select a value from your flag field, qlik associative engine itself would filter the data accordingly. I am not sure if am missing anything here. Try using the expression I suggested and keep selecting different flag values - you should get what you need. Otherwise, to answer your very question try like:
If(GetFieldSelections(DayFlag)='AM Only, All Day', Count({<DayFlag={'AM Only', 'All Day'}>}Distinct OR_Date)
If you select two or more values, getfieldselections() would return them separated by a comma and a space. Also note, you don't need two counts for two values, you can pass multiple values in one set analysis like shown above.
Hey Tresesco
Thanks for the tips but unfortunately I have to do 2 separate counts due to the possibility of an OR_Date having any or all 3 of the flags.
When I used your logic below it worked perfectly, but I wanted to extend it then to all other possibilities (If 'All Day' and 'PM Only' were chosen do this.... but it didn't work.