Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
pascos88
Creator II
Creator II

is possible return 2 expression in one if condition?

I need to return 2 expression in one if condition.

i.e   

     if(vVariable = 'Yes', Only(A) and Only(B), if(vVariable='No', Only(C) and Only(D)))

A and B or C and D will be show like a bar in the same chart.

Thanks for replay

Pasquale

23 Replies
pascos88
Creator II
Creator II
Author

Hi Peter,

Thanks for the reply. Your exemple work well and the same that I looknig for.

But I can't understand the procedure.

You use 2 Text Object where MWh set Variable vSelectChar with Value MWh and the Text Object Revenue set Variable vSelectChar whit Value Revenue.

In the expression u use always the Value MWh

=IF ('$(vSelectChart)' = 'MWh', sum(Prod), sum(Rev))

=IF ('$(vSelectChart)' = 'MWh', sum(P50Prod), sum(RevBOT))

Also I can't understand why in the first expression for example you use sum(Prod) and sum(Rev) but the chat show the Value of P50Prod and Rev Bot.(the same situation in the second chart, u use sum(P50Prod) and sum(RevBOT) and the chart show me Rev e RevBot).

in the label for example you put =IF ('$(vSelectChart)' = 'MWh', 'Production', 'Revenue') and the result of legend is Production and P50Product .

Also you know if there is same feature to set in order to have 2 expression separate like you? I try in my work, but I have always the wrong value like in figure above that I posted yesterday.

Regards

Pasquale

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Of course I always use the same test value. My two expressions should display something different when MWh is select (first one Prod, second one P50Prod) than when Revenue is selected (first one Rev, second one RevBOT) Moreover they should act together.

There is no special feature to set. Also to help you understand what is happening (you're looking at this solution in the wrong way): the two expressions are always visible. Always. The first one is colored green, the second one is colored light blue. Always. What the different IFs do is change the label and expression for the first expression between Prod and Rev. That's the green one. At the same time the IFs change the label and expression for expression 2 between P50Prod and RevBot. That's the light blue one.

There are no expressions being hidden, no tricks being applied and no special switches being set. It's all very straightforward.

BTW When adding additional expressions and labels, you may want to change the expressions into a match/pick combo, as that technique will offer improved maintainability when you have to deal with more than 2 choices. For example, the first expression then becomes:

=Pick(Match('$(vSelectChart)',

            'MWh',    'Revenue', 'Opex',    'EBITDA',    'Liquidity'),

            Sum(Prod), Sum(Rev), expr1Opex, expr1EBITDA, expr1Liquidity)

Best,

Peter

pascos88
Creator II
Creator II
Author

Now, I get in . Really thanks for your help.

Have a good day.

Regards

Peter_Cammaert
Partner - Champion III
Partner - Champion III

If you feel like your question has been answered, please close the discussion by marking one answer as correct.

Select the post that most closely answers your original question. That answer will appear in the same frame as your OP (at the top of this thread), making it easier for other community members to check out your Request and its Solution. Thanks

Peter