Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

danielco223
New Contributor III

Multiple IF's in Set Analysis

Hi, I need multiple if statements in a measure based on dimensions selected. For example if you pick from [Fiscal - Year], [Fiscal - Quarter Id], or [Fiscal - Period Id], the corresponding measures should be calculated. Im not sure what the syntax would be though.

=if(

GetSelectedCount([Fiscal - Year])>0,

round(Sum({$<[Fiscal - Year]={$(=Max([Fiscal - Year])-1)},[Filter - Date Context]={'Shipped'}>}[Amount - Shipped/Fulfilled USD])))

Or

=if(

GetSelectedCount([Fiscal - Quarter Id])>0,

round(Sum({$<[Fiscal - Quarter Id]={$(=Max([Fiscal - Quarter Id])-4)}>}[Amount - Shipped/Fulfilled USD])))

Or

=if(

GetSelectedCount([Fiscal - Period Id])>0,

round(Sum({$<[Fiscal - Period Id]={$(=Max([Fiscal - Period Id])-12)}>}[Amount - Shipped/Fulfilled USD])))

Thanks!

Dan

1 Solution

Accepted Solutions
zebhashmi
Valued Contributor

Re: Multiple IF's in Set Analysis

=if(

GetSelectedCount([Fiscal - Year])>0,

round(Sum({$<[Fiscal - Year]={$(=Max([Fiscal - Year])-1)},[Filter - Date Context]={'Shipped'}>}[Amount - Shipped/Fulfilled USD],

if(

GetSelectedCount([Fiscal - Quarter Id])>0,

round(Sum({$<[Fiscal - Quarter Id]={$(=Max([Fiscal - Quarter Id])-4)}>}[Amount - Shipped/Fulfilled USD],

if(

GetSelectedCount([Fiscal - Period Id])>0,

round(Sum({$<[Fiscal - Period Id]={$(=Max([Fiscal - Period Id])-12)}>}[Amount - Shipped/Fulfilled USD])))

5 Replies
zebhashmi
Valued Contributor

Re: Multiple IF's in Set Analysis

Should work or you can use Pick(Match(),)

zebhashmi
Valued Contributor

Re: Multiple IF's in Set Analysis

=if(

GetSelectedCount([Fiscal - Year])>0,

round(Sum({$<[Fiscal - Year]={$(=Max([Fiscal - Year])-1)},[Filter - Date Context]={'Shipped'}>}[Amount - Shipped/Fulfilled USD],

if(

GetSelectedCount([Fiscal - Quarter Id])>0,

round(Sum({$<[Fiscal - Quarter Id]={$(=Max([Fiscal - Quarter Id])-4)}>}[Amount - Shipped/Fulfilled USD],

if(

GetSelectedCount([Fiscal - Period Id])>0,

round(Sum({$<[Fiscal - Period Id]={$(=Max([Fiscal - Period Id])-12)}>}[Amount - Shipped/Fulfilled USD])))

danielco223
New Contributor III

Re: Multiple IF's in Set Analysis

How could you use Pick and Match in this example?

zebhashmi
Valued Contributor

Re: Multiple IF's in Set Analysis

sasiparupudi1
Honored Contributor III

Re: Multiple IF's in Set Analysis

=Pick(

Match(GetSelectedCount([Fiscal - Year])>0,GetSelectedCount([Fiscal - Quarter Id])>0,GetSelectedCount([Fiscal - Period Id])>0

,

round(Sum({$<[Fiscal - Year]={$(=Max([Fiscal - Year])-1)},[Filter - Date Context]={'Shipped'}>}[Amount - Shipped/Fulfilled USD])),

round(Sum({$<[Fiscal - Quarter Id]={$(=Max([Fiscal - Quarter Id])-4)}>}[Amount - Shipped/Fulfilled USD])),

round(Sum({$<[Fiscal - Period Id]={$(=Max([Fiscal - Period Id])-12)}>}[Amount - Shipped/Fulfilled USD]))

)

Community Browser