Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
I got a parameterized variable in my App defined as follows:
sum({<Scenario={$1},NMY={$2},AGGREGATION_TYPE={$3},$(vL.Toggle.HC) ,$4>}HC)
so far it is working fine
but now I want to do a new logic inside the definition of this variable
I want to check if the value of the first parameter is 'actual' or 'budget' based on which there will be a new logic
I tried '$1' in an if condition but didn't seem to work
is there a way to accomplish this?
Hi @ali_hijazi
It is confusing what you are trying to do.
Given that you need to pass parameter 1 to variable you dont need to check what it is as you alerady know what you are passing as that parameter.
You may want to explain it with some other example to help us understand.
cheers
what I want to accomplish is the following:
when the value of the first parameter $1 is 'Actual' then
sum({<Scenario={$1},NMY={$2},AGGREGATION_TYPE={$3},$(vL.Toggle.HC) ,$4>}HC)
otherwise
{<field1={'value'}>}
sum({<Scenario={$1},NMY={$2},AGGREGATION_TYPE={$3},$(vL.Toggle.HC) ,$4>}HC)
I'm using this parameterized variable becuase it is used in several charts and I don't want to repeat the calculation expression and the condition in all charts but rather have it in one place
You may try:
{<field1={"$(=if($1 = 'Actual', 'value', '*'))"}>}
sum({<Scenario={$1},NMY={$2},AGGREGATION_TYPE={$3},$(vL.Toggle.HC) ,$4>}HC)
In general should an if-query against a parameter be possible. Just check the if-logic at first without the parameter and afterwards the parameter is replaced by the condition-value.
Another approach may be:
{<field1={$5}>}
sum({<Scenario={$1},NMY={$2},AGGREGATION_TYPE={$3},$(vL.Toggle.HC) ,$4>}HC)
Hello @marcus_sommer
it doesn't work as you suggested
if ($1 = 'actual'....
the editor gives an error
Hi @ali_hijazi
Works for me:
As I said passing parameter you already know and have to pass anyway does not make sense to me as it adds more complexity, but at the end if you are happy with that approach here is a sample app.
Obviously to accomodate $1 in If() condition you need create another variable with that parameter so that it can obtain and pass down the parameter you are trying ot pass.
It depends on how the parameter/variable is defined and called - both needs to be adjusted to each other. By defining the parameter like: $(v(Actual)) the call must be: '$1' - not mandatory within a set analysis because they expect a string and it's only necessary if the string contains spaces or special chars - but by using: $(v('Actual')) the call could be just $1.