Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Select variable in set expression only if it is selected

I have a list box which has Years and Quarters in it.I have defined a group Year_Quarter in Settings -> Document Properties -> Group and then I have made a list box from it.

My aim is to get YOY difference for sales amount.

In the Year_Quarter list box I select a Year but may or may not select quarter.So when I don't select a quarter I want difference between  the year selected and its previous year.

If I select a quarter then I want difference between selected (year quarter ) and previous (year quarter)

For example if I select Q12018 then I want difference with Q12017

But If I select only 2018 and dont select any quarter then I want difference with entire 2017

I wrote a set expression as follows for calculating difference

=sum({<Financial_Year = {'$(Selected_Year)'}, Quarter = {'$(Selected_Quarter)'}>} AMOUNT) - sum({<Financial_Year = {'$(Previous_Year)'}, Quarter = {'$(Selected_Quarter)'}>} AMOUNT)

Where

      Selected_Year = GetFieldSelections(Financial_Year)

      Selected_Quarter = GetFieldSelections(Quarter)

     Previous_Year = GetFieldSelections(Financial_Year)  -1


The problem in the above expression that it needs to be selected as well.How can I edit the above expression such that take Quarter only if .I have selected quarter else dont use quarter value just use year value

1 Solution

Accepted Solutions
PabloTrevisan
Partner - Creator II
Partner - Creator II

Hi Nishant,

You've already tried an 'if' statement ?

Example:

if (GetSelectedCount (Quarter) > 0, expression to calculate the quarter, expression without considering the quarter)

I do not know if this helps ?

View solution in original post

3 Replies
PabloTrevisan
Partner - Creator II
Partner - Creator II

Hi Nishant,

You've already tried an 'if' statement ?

Example:

if (GetSelectedCount (Quarter) > 0, expression to calculate the quarter, expression without considering the quarter)

I do not know if this helps ?

Anonymous
Not applicable
Author

Thanks It works as expected

andrey_krylov
Specialist
Specialist

Not quite clear, but it looks like you do not need to put Quarter = {'$(Selected_Quarter)'} in set analysis