Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

Announcements
Save the Date: QlikWorld Online, June 24-25, 2020. Free global virtual event for data integration and data analytic gurus. Register Today
Contributor II

Nested IF statements in a Text Object

I have a Text Object with an expression in the Text that produces a percentage based on user selections.  I have two selections that I need to test for and each test will use a different set of variables to calculate that percentage.  How can I write the expression to best return the result I am looking for?  Here are the IF statements listed out on their own that I am looking to combine into one large expression.

=If((vFlag) = 'Yes' and Division = 'A', vProjAFYSavings, vFYASavings)

=If((vFlag) = 'Yes' and Division <> 'A', vProjFYSavings, vFYSavings)

=If((vFlag) = 'No' and Division = 'A', vFYASavings, vFYASavings)

=If((vFlag) = 'No' and Division <> 'A', vProjFYSavings, vFYSavings)

1 Solution

Accepted Solutions
Highlighted
MVP
MVP

Re: Nested IF statements in a Text Object

Assuming Flag can either be Yes or No:

=If(Flag = 'Yes',

     If(Division ='A',vProjAFYSavings, vProjFYSavings),

     If(Division = 'A', vFYASavings, vProjFYSavings)

)

View solution in original post

3 Replies
Highlighted
MVP
MVP

Re: Nested IF statements in a Text Object

Not sure if these can be combined at all.

For example, If Division <> 'A' and vFlag = 'No', the second expression will return vFYSavings, while the fourth vPrjFYSavings.

In general, you can use nested if() statements like

=If( ConditionA, Then1, If( ConditionB, Then2, If(Condition3, Then 3, Else1)))

or

=If(ConditionA, If(ConditionB, Then1, Else1), Else2)

etc.

Highlighted
Contributor II

Re: Nested IF statements in a Text Object

Yes, agreed.  Could you show me how to nest these IF statements?

Highlighted
MVP
MVP

Re: Nested IF statements in a Text Object

Assuming Flag can either be Yes or No:

=If(Flag = 'Yes',

     If(Division ='A',vProjAFYSavings, vProjFYSavings),

     If(Division = 'A', vFYASavings, vProjFYSavings)

)

View solution in original post