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: 
dmohanty
Partner - Specialist
Partner - Specialist

Use of Variable in Set Analysis?

Hi All,

I am calculating YES and NO using certain condition and storing in a Variable.

For example, vYesNo = if ( Avg(Total) - Avg(Actual) > 1 , 'YES' , 'NO')

and using the same variable I have to Count a certain dimension. For example:

Count (Materials) where vYesNo = 'YES' (have to use this variable in Set Analysis - HOW?)

Count (Materials) where vYesNo = 'NO' (have to use this variable in Set Analysis - HOW?)


Can someone please help here - How to use the variable in Set Analysis?

7 Replies
danieloberbilli
Specialist II
Specialist II

Set Analysis deals mainly with fields. If you would have a field F1 with the values YES and NO, you could use your variable to control this like

count({<F1={$(vYesNo)}>}  Materials)

but in your case you wouldnt use set analysis and rather somthing like

count (if($(vYesNo)='YES', Materials)

dmohanty
Partner - Specialist
Partner - Specialist
Author

Hi Daniel,

Thanks for some help.

But as, by calculated variable is using Aggregation Function, so using the variable in Count(). is not allowing to do a Nested Aggregation.

Any other help please?

danieloberbilli
Specialist II
Specialist II

could you describe a bit more the situation (object/dimension/data)? At the moment, I don't consider this as a nested aggregation but a simple condition resulting in true/false. A nested aggregation would be sth like sum(aggr(count...))

danieloberbilli
Specialist II
Specialist II

ah - I think see what you mean - sorry - I thought you are calculating the variable only once in the script - but its dynamic on the dashboard level

danieloberbilli
Specialist II
Specialist II

what about

=if($(vYesNo)='YES', count(Materials))

=if($(vYesNo)='NO', count(Materials)) ?

dmohanty
Partner - Specialist
Partner - Specialist
Author

Yes,

I am calculating the variable at script level and using the formula in a Text Object.

But this has not helped either

danieloberbilli
Specialist II
Specialist II

maybe you should post an example qvw with dummy data and also what result you would expect.

In my case I dont see any problem when creating a dummy by myself.