23 Replies Latest reply: Nov 27, 2015 10:04 AM by Peter Cammaert

# 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

• ###### Re: is possible return 2 expression in one if condition?

could u share any sample data

• ###### Re: is possible return 2 expression in one if condition?

Maybe I can't because I have just trial Version. I try to be more clarify.

I have 5 expression A B C D E.

If (myVariable=1, Only(A) and Sum(B), if(myVariable=2, Only(C) and Only (D), Sum(E)))

The format of expression look good, but dosn't work

I would to have this solution and use just one bar chart. The dimension is always the same.

I don't know, maybe there is another solution to show 2 expression with a define condition.

• ###### Re: is possible return 2 expression in one if condition?

If condition is true, you have x and y. Do you want them to be added ?

• ###### Re: is possible return 2 expression in one if condition?

Yes, where x e y are 2 Expression

• ###### Re: is possible return 2 expression in one if condition?

Hi,

What exactly you trying to do?

You can turn any amount of expression conditionally, but depends what you mean if this would apply or not.

Mark

• ###### Re: is possible return 2 expression in one if condition?

Could you share sample data ?

And also explain little bit more.

• ###### Re: is possible return 2 expression in one if condition?

I want use one bar char that change the expression inside when change the variable selected.

I have this two chart and the variable that I use are the boton up (Mwh, Revenue, Opex etc)

I would like have  just the first chart, that change dynamically the expression inside.

If MWh is selected my expression will be Production and P50 Product; if I select the variable Revenue, my expression should change in Revenue and Revenue BGT.

I need to insert some condition in expression that return me two condition.

I hope that is more easy to understand in this way

• ###### Re: is possible return 2 expression in one if condition?

Hi Pasquale,

Exactly i don't no ,but may be helpful for you

sample:

dim,A,B,C,D,E

a,1,2,3,4,5

b,9,8,7,5,6

];

When click a in dim

when click b in dim

• ###### Re: is possible return 2 expression in one if condition?

thanks for the reply. but can't works for me because it show in the legend all expression even if is not used in a chart. I thought about this but I need a find another way ..

Really thanks

• ###### Re: is possible return 2 expression in one if condition?

Hi,

If you want to conacatenate output of two expression

then try like

If (myVariable=1, Only(A) &' : ' & Sum(B), if(myVariable=2, Only(C) & ' : ' & Only (D), Sum(E)))

Regards

• ###### Re: is possible return 2 expression in one if condition?

Hi Max,

Yes I want concatenate two expression.

I tried this but doesn't work. the chart show me just one expression, that is a strange number (I don't know which kind of operation the tool do). I would like to show separate bar one for A and another for B.

• ###### Re: is possible return 2 expression in one if condition?

Try like:

If (myVariable=1, RangeSum(Only(A), Sum(B)), if(myVariable=2, RangeSum(Only(C), Only (D)), Sum(E)))

• ###### Re: is possible return 2 expression in one if condition?

Hi ,

thanks for help me, but dosn' t work yet.

this is the result, I have just one bar (I would like separare bar), where the value is a strange number.

What u thinking about? Maybe  you know a different way to do this?

Really thanks

• ###### Re: is possible return 2 expression in one if condition?

If you want two bars, you'll need two expressions. If they are interchangeable, just have one be Only(A) or Only(C) and the other be Only(B) or Only(D) - that way you'll have two bars, either A and B or C and D.

• ###### Re: is possible return 2 expression in one if condition?

Something like this? I only made it with two buttons. The others follow a similar logic, but you didn't specify what should be displayed when clicking for example 'Opex'.

• ###### Re: is possible return 2 expression in one if condition?

Hi Peter,

but you used two different chart or just one? Regarding Opex I have other data but if I can do it for MWh and Revenue, I will do the same for other botton.

• ###### Re: is possible return 2 expression in one if condition?

No, this is one chart that dynamically changes almost everything when you press a different button at the top.

If you're not using a PE Desktop, you can use the document in attachment to figure out how these screenshots were made.

Best,

Peter

• ###### Re: is possible return 2 expression in one if condition?

It is just what I need. But I can't see the attach document. where is it?

• ###### Re: is possible return 2 expression in one if condition?

regards

Marco

• ###### Re: is possible return 2 expression in one if condition?

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

• ###### Re: is possible return 2 expression in one if condition?

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

• ###### Re: is possible return 2 expression in one if condition?

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

Have a good day.

Regards