Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

check for any selection in field & if in sum

Hi All

I need to check if any value has been selected in a particular field. I've been playing with getfieldselections but not come up with a decent solution. The field contains text values. The below does work but seems wrong to be doing a numeric comparison on a text field?

[CODE]

=



getfieldselections([5CCN - Level 5 Cost Centre Name])>0

[/CODE]

This gives -1 if a value has been selected.

Another question. I have to extablish whether based on the current selection there is any value in a particular selection, I'm using an if statement like:

[Code]

=if(sum(if([4AN - Level 4 Account Name]='Income',Actuals*CY_Flag))=0 ,'blah,'blah blah')

I know if statements in sums are inefficient, is there a better way to do this?

Many thanks

Dominic



3 Replies
Not applicable
Author

Use GetSelectedCount if you just want to check if there are selections. GetFieldSelections returns a delimited list of those selections:

=GetSelectedCount([5CCN - Level 5 Cost Centre Name])>0


As for your second question, I don't know if you can get rid of both ifs. Using Set Analysis may get rid of one:

=if(
sum({<[4AN - Level 4 Account Name]={'Income'}>} Actuals*CY_Flag)=0
,'blah,'blah blah')


Not applicable
Author

Perfect thanks!

As for the other question, I'm trying to see what income is in the current select, I understand if I use set analysis it would sum income regardless of selection?

Not applicable
Author

No, the default for Set Analysis is to respect selections. This would respect selections (the $ is the default and not required):

=if(
sum({$<[4AN - Level 4 Account Name]={'Income'}>} Actuals*CY_Flag)=0
,'blah,'blah blah')


This would ignore selections:

=if(
sum({1<[4AN - Level 4 Account Name]={'Income'}>} Actuals*CY_Flag)=0
,'blah,'blah blah')