Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
madnanansari
Creator
Creator

Convert if statement to pick - match function

How to convert the below if statement to pick - match combination:

If(getselectedcount([Year])<1 and getselectedcount([Month Year])<1

,

Sum({$<[Month Year]=,[Year]=,[MonthID]= {"$(=((Year(Today()) -1)*12) + Num(Month(Today())))"}>} [Target])

,

Sum([Target])

)

4 Replies
sunny_talwar

I don't think this can be converted to a pick match statement....

swuehl
MVP
MVP

Maybe you can use a pick/ match combination here, but I believe without any benefit.

Pick( Match( getselectedcount([Year]) &'-'& getselectedcount([Month Year]), '0-0'),

...

pradosh_thakur
Master II
Master II

Try this

pick(match(getselectedcount([Year])&getselectedcount([Month Year]) ,'00')+1, Sum([Target]),Sum({$<[Month Year]=,[Year]=,[MonthID]= {"$(=((Year(Today()) -1)*12) + Num(Month(Today())))"}>} [Target])


regards

Pradosh


Learning never stops.
swuehl
MVP
MVP

Yes, like pradosh suggested, you should use a +1 to account for a default value and change the order of expressions accordingly.

But still, I believe this won't perform better nor be better maintainable than the original If().