Skip to main content
Announcements
YOUR OPINION MATTERS! Please take the Qlik Experience survey you received via email. Survey ends June 14.
cancel
Showing results for 
Search instead for 
Did you mean: 
cliff_clayman
Creator II
Creator 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
swuehl
MVP
MVP

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
swuehl
MVP
MVP

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.

cliff_clayman
Creator II
Creator II
Author

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

swuehl
MVP
MVP

Assuming Flag can either be Yes or No:

=If(Flag = 'Yes',

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

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

)