Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using GetCurrentSelections as a Calculation Condition?

I'm trying to use GetCurrentSelections as a calculation condition for a particularly large straight table.  I want users to select at least three conditions to limit the amount of data that is returned and prevent the report from running too slowly.

Here's what I have:

=count(GetCurrentSelections())>=3

But the QlikView application crashes when I run this.

Based on this discussion I've also tried

=len(GetCurrentSelections())>=3

This doesn't crash, but it also doesn't produce an error when fewer than three conditions are selected.

Any suggestions very much appreciated. 

5 Replies
swuehl
MVP
MVP

GetCurrentSelections() will return the selections in a string, so I believe the count of that string will never be larger than 1.

You can look into the optional arguments to GetCurrentSelections() to set special delimiter for records and values, and then use a substringcount to check the number of fields you selected in:

=SubStringCount( GetCurrentSelections('\'),'\') >= 2

(I am only comparing to 2 since a delimiter is separating two fields.

Not applicable
Author

you can do a little trick:

=substringcount (getcurrentselections (chr(13), '=', ';', 10 ),'=')

Not applicable
Author

Thanks very much, both answers are very helpful.

We decided to go a different way and use GetPossibleCount to limit the possible returns to 10,000.  If there are more than that the user gets an error message saying 'Not enough selections.  Please apply more filters.' until fewer than 10K records are returned.

That solved the speed problem.

Not applicable
Author

Hi,

I believe you need to have a field name in your expression:

Like:

len(GetCurrentSelections(FieldName))>=3

Regard

Rahul

Not applicable
Author

Hi Rahul, thank you for your input.  We didn't want to limit the selection to one particular filter, we wanted at least three of the filters available to be selected.