Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Folks,
I have a variable in my script that is
Set var_IAP= =Sum({<Tipo_ap={Produção}, ETAPA-={50,21,100}>} QUANTIDADE)
'Etapa' exclusion is very common and I need to change it frequently (include another number like 200), so I created a new variable:
Set var_etapa_excluir= , ETAPA-={50,21,100};
And now I am trying to nest both using:
=Sum({<Tipo_ap={Produção} var_etapa_excluir >} QUANTIDADE)
Note that in many cases I need to exclude 'Etapa', but not in all cases. So my concern is to use as a variable, to avoid editing all the script that has more than 20 other variables.
In chart I just use var_IAP.
What is the correct way to nest variables in script? What am I doing wrong?
Thanks and best regards.
This should work:
Set var_etapa_excluir= , ETAPA-={50,21,100};
Set var_IAP = =Sum({<Tipo_ap={Produção} #(var_etapa_excluir) >} QUANTIDADE);
Let var_IAP = Replace(var_IAP, '#', '$');
The reason for two steps for var_IAP is to defer the $ expansion of var_etapa_excluir until the expression is evaluated in the front end. "Set" will expand the variable so it will no longer be dynamic.
We substitute # for $ to prevent the expansion and put it back with the replace step. The replace does not trigger the expansion.
You may get syntax warnings because the syntax check does not know what you intend to do with the variables.
You might have to play around with this to get this to work:
Re: Expression as a variable with $-sign expansion
Stop Dollar Sign Expansion in the script (Escape Character ??? )
Not sure if I have understood you correctly ? If you say you have to exclude ETAPA for some cases so why cant you put that case outside the SET like
If case1 , sum({<ETAPA-={0,1,200}> } amount) else sum(amount) and do you really need to create 2 variables as you can edit the filters in the ETAPA even if you use 1 variable
This should work:
Set var_etapa_excluir= , ETAPA-={50,21,100};
Set var_IAP = =Sum({<Tipo_ap={Produção} #(var_etapa_excluir) >} QUANTIDADE);
Let var_IAP = Replace(var_IAP, '#', '$');
The reason for two steps for var_IAP is to defer the $ expansion of var_etapa_excluir until the expression is evaluated in the front end. "Set" will expand the variable so it will no longer be dynamic.
We substitute # for $ to prevent the expansion and put it back with the replace step. The replace does not trigger the expansion.
You may get syntax warnings because the syntax check does not know what you intend to do with the variables.
I think my explanion was not clear, but below explanation may help:
I have 100 variables and 80 of them contain <ETAPA-={0,1,200}>. If I want to include one ETAPA number into array like <ETAPA-={0,1,200,205}>, will I need to change 80 lines of code?
Yeahh... it worked!
Thank you so much.