Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

IF Statement inside Set Analysis

Hi all,

I want my expression to show the sales amount of the latest month if no months are selected (Field: DW_SK_Date). However, if one or multiple months are selected the expression has to show the selected months.

I have a field (IsCurrent) that specifies if it is the latest month (ISCurrent=1) or not (ISCurrent=0).

I have tried to make a variable with the IF Statement and then put it into a set expression (see below), but it does not work.

Can someone please help me out?

Variable: vISCurrent = IF(GetSelectedCount(DW_SK_Date)=0,1,0)

Set Expression: Sum({<IsCurrent={$(vISCurrent)}>}Amount)

Please see my test dataset attached

Kind Regards,

Thomas

1 Solution

Accepted Solutions
sunny_talwar

How about this?

Sum({<IsCurrent={$(=If(GetSelectedCount(DW_SK_Date)=0,1,0))}>}Amount)

View solution in original post

6 Replies
sunny_talwar

Try this may be

Sum({<IsCurrent={$(=vISCurrent)}>}Amount)

Anonymous
Not applicable
Author

Still does not work, unfortunately

sunny_talwar

How about this?

Sum({<IsCurrent={$(=If(GetSelectedCount(DW_SK_Date)=0,1,0))}>}Amount)

Anonymous
Not applicable
Author

That seems to work. Thanks!

Do you know why it does not work with a variable? Or what I can do to put it into a variable, as I will have to make this calculation in several other expressions?

sunny_talwar

Does you variable include the = sign or not?

=If(GetSelectedCount(DW_SK_Date)=0,1,0)

Try adding or removing it and see if that makes any difference?

Anonymous
Not applicable
Author

You're right.

It removes the equal sign in front of the variable if I am typing the expression in the expression editor (fx), however if I type it directly in the definition dialog box it keeps it - Weird

Anyway, thanks a lot for your help.