Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
tobiasaechter
Contributor III
Contributor III

calculation condition with getselectedcount ()

Hi, 

I have a table which I would like to conditionally show/hide depending on the users selection in a list box.

I have tried using the calculation condition with various approaches:

- "getSelectedCount(Field)>0" -> the table is always hidden, independently on any selection in "Field"

- "Count(Field)>0" -> the table does not hide at all.

Can anyone help me understanding what I am doing wrong?

Thanks

Labels (1)
15 Replies
tobiasaechter
Contributor III
Contributor III
Author

in a simplified setup I have four fields: Country, Business, Year, Order Volume
My table has country and business as dimension and SUM(Orders) as measure.
the calculation condition is: len(GetCurrentSelections(Business))>0

I would have expected that if any value in the field business is selected the table should show/calculate the data. whereas any selection in country or year would not have any influence on the calculation condition.

but the actual behaviour is that any selection in business, country or year does trigger the calculation condition.

marcus_sommer

The proper way is: getselectedcount(TheRightField). Nearby would be: len(getfieldselections(TheRightField)) by adding an extra layer. Instead of this would be getcurrentselections() in general also be usable but with a lot of extra efforts to extract the relevant information.

Like above mentioned take a closer look on the real field-names which may differ to the ones which are shown - maybe any qualifying-information is removed or something similar ...

Further make sure that all relevant objects are within the same selection-state (if any alternate states are applied).

tobiasaechter
Contributor III
Contributor III
Author

I think I have figured out the issue.

using getselectedcount(Field) works, but the issue was that I had pre-filtered my field in the filter pane's dimension.
like my Field has values 1,2,3,4,5 and in my filter pane I had used "if(not match(Field, '3'), Field)" because I did not want the user to be able to select the value 3 in this field.
If I then tried to select in this filter pane the chart did not react. But if I am not pre-filtering the field the calculation condition works like expected.

vinieme12
Champion III
Champion III

I'd second what @marcus_sommer has suggested

Add the following expression in a textbox and make sure the count is updating when you make selections

=GetSelectedCount(Field)

If the numbers don't change as you select values in that field there are only 2 possible reasons

1) alternate states in play

2) wrong field being referred Field and field are two different fields as field names are case sensitive

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
tobiasaechter
Contributor III
Contributor III
Author

is it possible that Qlik thinks the field name changes if I have a list box where the dimension is "Field" vs "=if(not match(Field, 3), Field)"
I would have assumed the field name is the same in both cases. But this is where the issue was coming from.

marcus_sommer

It's not a native field anymore else a calculated dimension. In general such approaches should be rather avoided because it didn't only effects selections else prevents the usage of aggr() and/or TOTAL statements and impact the performance.

In your case it would be probably better to double the field within the data-model - ones complete for admin and power users and the second one with a NULL() replacement for the unwanted values. If there are various value-combinations and/or fields to consider it would hint for the usage of section access to implement a real access control on a user-level.