Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need a sample of code for IF/ELSE stament whe Selecting two or more month or year?

Can someone help me find a code for that?

13 Replies
Anonymous
Not applicable
Author

If(

getselectedcount([Month])>=2 OR getselectedcount([Year])>=2,

sum({$<[Location] -= {'790','791','793','794','795','796','797','798','799','R12086','R14030','R14031'},[APP] -= {'CE'}, [Unit of Measure] -= {'BBM'} >} AMDOL),

//else one month is selecte then

sum({$<[Location] -= {'790','791','793','794','795','796','797','798','799'},[APP] -= {'CE'} >} AMDOL))

awqvuserneo
Creator
Creator

Looking at your set analysis, it seems the logic is as follows:

If 2 or more month is selected:

  get a sum(AMDOL), BUT EXCLUDE those location and EXCLUDE (APP=CE), and also EXCLUDE (Unit of Measure]=BOM)

else

  get a sum(AMDOL), BUT EXCLUDE those location and EXCLUDE (APP=CE)


Is this what you're trying to achieve? (which pretty much sum of AMDOL but exclude those different criteria?

OR are you trying to achieve:


If 2 or more month is selected:

  get a sum(AMDOL), WHERE it includes those location and WHERE (APP=CE), and BUT EXCLUDE (Unit of Measure]=BOM)

else

  get a sum(AMDOL), WHERE it includes those location and WHERE (APP=CE)?




Not applicable
Author

Thanks Janet, that worked

Anonymous
Not applicable
Author

you welcome!