1 Reply Latest reply: Mar 7, 2013 6:26 AM by Tyler Waterfall

# Writing nested if conditions in set expressions

=

if(y='Cases',

if(GetFieldSelections(Flags)='1_Flag',sum({<1_Flag={'1'},BudgetIndicator=>}(Value)/denoname),

if(GetFieldSelections(Flags)='2_Flag',sum({<2_Flag={'1'},BudgetIndicator=>}(Value)/denoname),

if(GetFieldSelections(Flags)='3_Flag',sum({<3_Flag={'1'},BudgetIndicator=>}(Value)/denoname),

if(GetFieldSelections(Flags)='4_Flag',sum({<4_Flag={'1'},BudgetIndicator=>}(Value)/denoname))))),

if(GetFieldSelections(Flags)='1_Flag',sum({<1_Flag={'1'},BudgetIndicator=>}(Value*Conversion)/denoname),

if(GetFieldSelections(Flags)='2_Flag',sum({<2_Flag={'1'},BudgetIndicator=>}(Value*Conversion)/denoname),

if(GetFieldSelections(Flags)='3_Flag',sum({<3_Flag={'1'},BudgetIndicator=>}(Value*Conversion)/denoname),

if(GetFieldSelections(Flags)='4_Flag',sum({<4_Flag={'1'},BudgetIndicator=>}(Value*Conversion)/denoname))))))

only some part of the above expression is set expression.But is there anyway that i can write the above entire thing in set expression so that it can maximize the performance.

Thanks,

Hari

• ###### Re: Writing nested if conditions in set expressions

Could you do something to the effect of:

SUM( {<\$(=GetFieldSelections(Flags))_Flag={1},BudgetIndicator=>} Value/denoname)

you  might have to play with the \$(= syntax a little to get it to work...  you could do something similar for the y=cases bit ... just add the two expressions:

SUM( {<\$(=GetFieldSelections(Flags))_Flag={1},y={"Cases"},BudgetIndicator=>} Value/denoname) +

SUM( {<\$(=GetFieldSelections(Flags))_Flag={1},y=-{"Cases"},BudgetIndicator=>} Value*Conversiondenoname)

Also - this discussion is better suited for the general QlikCommunity as opposed to the QlikView expressor community.

Let me know how this goes.