Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
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?

1 Solution

Accepted Solutions
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))

View solution in original post

13 Replies
Not applicable
Author

???????

awqvuserneo
Creator
Creator

Hi Lahib,

Are you looking for this?

If(getselectedcount([MonthField])>2 OR getselectedcount([YearField])>2, do X, do Y) ?

Best regards,

-A

Anonymous
Not applicable
Author

Exactly,  what  do you want  do?

Not applicable
Author

can this be used part of the set analysis?

If (getselectedcount([MonthField])>=2 OR getselectedcount([YearField])>=2,

SUM (X),

else

SUM (Y)

robert_mika
Master III
Master III

I assume you are looking for VBA?

If what?Then

Else what?

awqvuserneo
Creator
Creator

Depends...What your set analysis look like?

Not applicable
Author

I am looking for Set Analysis statement like this:

//if more than one month is selected then we need to exclude  [Unit of Measure] -= {'BBM'}

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)

this one is not working for me. I appreciate your help

Not applicable
Author

I am looking for Set Analysis statement like this:

//if more than one month is selected then we need to exclude  [Unit of Measure] -= {'BBM'}

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)

this one is not working for me. I appreciate your help

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),

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