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)
1 Solution

Accepted Solutions
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).

View solution in original post

15 Replies
MatheusC
Specialist
Specialist

@tobiasaechter 

Hi,  
are you inserting double quotes ""?
if it is removed from the expression.

GetSelectedCount(Field)>0

MatheusC_0-1704472424455.png

Att, Matheus

 

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
tobiasaechter
Contributor III
Contributor III
Author

No I didn’t use double quotes. Just this:  getSelectedCount(Field)>0

I only used the double quotes here in the question. 

MatheusC
Specialist
Specialist

@tobiasaechter 

According to what you said, I don't see any error in the expression, remembering that:

Hiding graphs using a condition inserted in the Add-ons -> Data handling -> Calculation condition.

Getselectcount() will return the current number of selected values ​​in the field.

Review the information, if you are unable to resolve the issue, provide more details on the matter.

Att, Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
tobiasaechter
Contributor III
Contributor III
Author

Well yes I understand that Getselectcount() will return the current number of selected values ​​in the field.

hence I am not totally sure if this is the correct expression to begin with. That is why I tried the count() as well.

happy to learn if you have any suggestion for a better expression to use here. 

MatheusC
Specialist
Specialist

@tobiasaechter 
maybe this:

GetCurrentSelections()) for the selections in a string, len for the number of characters
len(GetCurrentSelections())>0
or
 Len(Trim(GetCurrentSelections()) > 0)

 greetings

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
tobiasaechter
Contributor III
Contributor III
Author

len(GetCurrentSelections())>0

this does work, thanks, but can I also specify one specific field in the brackets?


like: len(GetCurrentSelections(Field1))>0 ?

I have tried this but it seems even if I add a specific field (Field1), the table still shows/hides as soon as I do a selection in any of the fields in my data model.

Ideally I would like to achieve the following:

(len(GetCurrentSelections(Field1))>0 and len(GetCurrentSelections(Field2)) = 'X') or len(GetCurrentSelections(Field3))>0

is this even possible?

 

 

vinieme12
Champion III
Champion III

Just the below is sufficient for a calculation condition

=getSelectedCount(Field) 

However can I ask what do you mean by Show / Hide? are you trying to completely hide the chart object?  calculation condition is only meant for enable/disable chart evaluation  not show/hide chart object !

 

the table is always hidden, independently on any selection in "Field"  << is the "Field" in  an alternate state??

if yes then you need to specify the statename in

=getselectedcount(Field,False(),'statename')

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

sorry for not being clear. I meant show/hide the values in the table. I understand that calculation condition does not make the whole table disappear, but rather disables/enables the values shown/calculated in the table. 
This is exactly what I would like to achieve. 

If there is no selection the table should show a message like "please select at least one value in Field 1 and 2 or field 3".  In case of any selection in these specified fields the table should show/calculate the data.

I am not using any alternate states.
=GetSelectedCount(Field) did not seem to work at all though. With this expression the table never calculates the data but always shows the message that the calculation condition is not fulfilled.

Whereas len(GetCurrentSelections(Field1))>0 seems to work, but I cannot specify any field so far. It rather disables/enables the chart evaluation for any selection in any field.

marcus_sommer

Make sure that you are calling the right field with the correct typing and not referring to a label for a field or to a calculated dimension.