Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I currently have the below expression running for my bar chart, which is not a problem :
=if((Today()-[Sent Date Time])<0, '<1',
if((Today()-[Sent Date Time])> 0 and (Today()-[KCI Sent Date Time])<5, '<5',
if((Today()-[Sent Date Time])>=5 and (Today()-[KCI Sent Date Time])<10, '>5',
if((Today()-[Sent Date Time])>=10 and (Today()-[KCI Sent Date Time])<15, '>10',
if((Today()-[Sent Date Time])>=15 and (Today()-[KCI Sent Date Time])<20, '>15',
if((Today()-[Sent Date Time])>=20, '>20'))))))
However, I was wondering if I could incorporate the Else if statement to this expression, so that it doesn't run through all conditions, and ends once it's found just ONE in any condition.
E.g. if there is data that meets the first condition, then it'll go into that first bucket, thus ending the if statement rather than continuing on.
Thanks,
Terence
Nope. Why is it not a good idea to use nested IF statements.
Qlik evaluates entire IF statement to cache the results.
okay thanks! That makes sense 🙂
Do you happen to know of a better alternative to using IF statements then?
In the link that I provided, it recommends Alt(), Pick(), Match(), MixMatch() and WildMatch() as alternatives.
You can make it simpler by testing high to low, eliminating the "and"s:
if(Today()-[Sent Date Time]) >= 20, '20'
,if(Today()-[Sent Date Time]) >= 15, '15'
,etc..
That will not eliminate the calculation of all branches, but it will make it easier to write and read.
-Rob