Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hey guys,
I have a Master Dimension defined as "State_City". It's two layers (i use hierarchy), so I can show measures for the State and the Cities in the same table column, according to the selection. For this, I use the function GetObjectDimension in the chart, as in:
=if(Getobjectdimension() = 'State', number_for_the_state, number_for_the_city)
Since I use this function in more than 1 place, i'd like to define a variabale "vNumber" with the expression above in the data load script, so instead of re-writing the expression every time I could just write in the chart:
=$(vNumber)
But when i define the variable in the data load script
let vNumber '=if(Getobjectdimension() = 'State', number_for_the_state, number_for_the_city)'
the function getobjectdimension() does not work. I tried changing the syntax, since the ' causes problems, and in the end got to the expression below
let vNumber = '(IF(GetObjectDimension() = '&chr(39)&' State '& chr(39) &' , Number_for_the_state, number_for_the_city))';
The expression is evaluated by QS, but it still does not compute the function getobjectdimension.
Am I doing something wrong? How could I use this function in this case? I know it is a chart and not a script function, but since i'm only defining it in the script, and using it in the chart, my guess is that it would work.
Thanks in advance!
Try:
SET vNumber = if(Getobjectdimension() = 'State', number_for_the_state, number_for_the_city);
And you must reference the variable in your chart expression using the $(variable) syntax.
-Rob
Try:
SET vNumber = if(Getobjectdimension() = 'State', number_for_the_state, number_for_the_city);
And you must reference the variable in your chart expression using the $(variable) syntax.
-Rob
The combination of SET + $ worked perfectly. Thank you, Rob.