Forum Discussion
kyrpav
Helper V
4 years agoFORMAT function with standard string and 1 decimal digit
I have a pivot table and for the calculation of the values i am using a switch statement. For each different row i have a different calculation. Code of each row is like this: SWITCH(S...
- 4 years ago
Yes that's the idea.
I would suggest you use variables to avoid evaluating the same measure(s) multiple times.
The code I posted earlier was what I was thinking as far as structure:
- Store the measure itself in one variable MeasureValue (T_01, T02 etc).
- Then store the chosen format string in a second variable
- Finally, format the measure using the format string
kyrpav
Helper V
4 years agoI was thinking the same thing if i understand well to do it like
switch(selectedvalue(v_raw_data[metric_code]),
"T_02",if(TRUNC([T_02])=[T_02],FORMAT([T_02],SELECTEDVALUE(v_raw_data[value_formatter])),FORMAT([T_02],"##0.0"))
but i did not like to run the same function too many times. What you propose to split it also i think is better.
OwenAuger
Super User
4 years agoYes that's the idea.
I would suggest you use variables to avoid evaluating the same measure(s) multiple times.
The code I posted earlier was what I was thinking as far as structure:
- Store the measure itself in one variable MeasureValue (T_01, T02 etc).
- Then store the chosen format string in a second variable
- Finally, format the measure using the format string