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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
robinwiman
Creator
Creator

How to combine Set expressions with If statements

I have the following code in my expression:

Sum ({<[Store Type2] = {'Concept', 'Estore', 'HQ Ret','SiS','Soft shop'}>} If(WildMatch(SeasonCalc, vCurrentSeasonCalc),Fsgantal*_YTD_TW_TY))

The above is supposed to return the following output:

If(WildMatch(SeasonCalc, vCurrentSeasonCalc) = Should return the season as 181S in this case, it builds on the calculations I have in my script: LET vCurrentSeasonCalc = Right(Year(Today()-7), 2) & IF(VECKANRTMP < '27','1','2') & '*';

{<[Store Type2] = {'Concept', 'Estore', 'HQ Ret','SiS','Soft shop'}>} = Is the set expression to only pick the store types I'm interested at this point.

Fsgantal = Amount sold


_YTD_TW_TY = Year to date, this week, this year


What happens is that the expression does not take both the set expression and the If statement into account, which I need it to.


Similarly, I have an issue when there are two (2) set expressions in the same Expression:


Sum ({<[Store Type2] = {'Concept', 'Estore', 'HQ Ret','SiS','Soft shop'}>} {<[Type Description] = {'men', 'ladies'}>} If(WildMatch(SeasonCalc, vCurrentSeasonCalc),Fsgantal*_YTD_TW_TY))


In the above, this is a new string:


{<[Type Description] = {'men', 'ladies'}>} = Makes sure that only Men and Ladies are taken into account, but can I still tell (by the sum total) that accessories, bags and wallets are still included.


So I guess the questions boils down to: How do I combine multiple set expressions together, as well as together with an If-statement?


1 Solution

Accepted Solutions
sunny_talwar

I am not sure why the Set and if statement doesn't work for you... I would have expected it to work...., but the second expression should be like this (just a comma separating the two sets instead of >} {<)

Sum({<[Store Type2] = {'Concept', 'Estore', 'HQ Ret','SiS','Soft shop'}, [Type Description] = {'men', 'ladies'}>} If(WildMatch(SeasonCalc, vCurrentSeasonCalc), Fsgantal*_YTD_TW_TY))


View solution in original post

2 Replies
sunny_talwar

I am not sure why the Set and if statement doesn't work for you... I would have expected it to work...., but the second expression should be like this (just a comma separating the two sets instead of >} {<)

Sum({<[Store Type2] = {'Concept', 'Estore', 'HQ Ret','SiS','Soft shop'}, [Type Description] = {'men', 'ladies'}>} If(WildMatch(SeasonCalc, vCurrentSeasonCalc), Fsgantal*_YTD_TW_TY))


robinwiman
Creator
Creator
Author

Thanks! the whole expression actually work now It seems that the error in the set expression gave me a wrong expression altogether. Everything works fine now.