Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Turning if statement into set analysis

Hi guys how do I change an if statement like this:

=if(if(operator= 'AAA' AND total_hours>0 , total_hours*resource_quantity, null())> 500, '>500', class(if(operator= 'AAA' AND total_hours>0 , total_hours*resource_quantity, null()), 30))

Into a statement witouth if but with set analysis. I know how to use set analysis with other functsions, apart from if..

4 Replies
tresesco
MVP
MVP

This is a misconception that all IFs can be replaced with set analysis. Try to share your business scenario, i.e. - how you would represent the report; using text box or any chart; if chart, what the dimension would be....

kuczynska
Creator III
Creator III

I think if you want to replace current expression with set analysis, you would have to create some flags in your load script (still using conditional IF statements) and then recall them in you set analysis. For example:

in load script:
if(operator= 'AAA' AND total_hours > 0, 1, 0) AS Flag1,

expression with set analysis:

sum({<Flag1 = 1>} total_hours*resource_quantity)

As tresesco‌ mentioned - stating that you can always replace IF with set analysis, is wrong. Split your IF statements into smaller chunks and create numeric flags in your load script. It will speed up your front end calculation.

Not applicable
Author

I see. I purely wanted to make use of set analysis so that any selections that I make do not influence other graphs.

I already make use of states, so that is not an option anymore since you can only assign one state per object.

sunilkumarqv
Specialist II
Specialist II

Hi Dutchsky,


Try like this if don't-want any other selections like Field1,Field2 below give example helps you i guess

If(sum({<operator={'AAA'},total_hours={'>0'},Field1=,Field2=>}total_hours*resource_quantity)>500,'>500'

Class(sum({<operator={'AAA'},total_hours={'>0'},Field1=,Field2=>}total_hours*resource_quantity),30))