Forum Discussion
Format String Expression to reflect absolute and percentage value
Hello,
I need to reflect value on a column chart in both absolute and percentage (in relate to other number) value. Example below.
In order to do so, I used format string expression in tabular editor. After many different tries I figured out something as below:
var wyk = FORMAT ( [Wykonanie], "\#,0;-\#,0;\#,0" ) var wyk_p = FORMAT ( [Wykonanie %], "0,0%;-0,0%;0,0%" ) return if ( selectedmeasurename() = "Wykonanie", CONCATENATE ( wyk, " / " & wyk_p ) )
but it formats the values in very strange manner (first row is correct - direcetly from measures, second row is result of format string expression).
Can anyone advise how I can resolve this? Thanks, Kamil
9 Replies
- vojtechsima
Super User
Hi, Anonymous
Try something like this:Formatting = var wyk = FORMAT ( MAX(SomethingSomething[Something]), "#,###,###.00") var wyk_p = FORMAT ( MAX(SomethingSomething[Something2]), "##.00%") return wyk & " / "& wyk_p- SergioSilvaPT
Resolver V
vojtechsima why you used the MAX function inside the FORMAT?
- vojtechsima
Super User
Hi, SergioSilvaPT
Just to make my sample data work, it is not necessary, but I didn't have row context so I had to help myself with MAX.
- SergioSilvaPT
Resolver V
Hi Anonymous ,
You can achieve the requested result with this measure:
IF( selectedmeasurename() = "Wykonanie", FORMAT([Wykonanie], "0.##") & " / " & FORMAT([Wykonanie %], "##.##%") )Regards,
Sérgio Silva
If this post helps, then please consider Accept it as the solution to help the others find it more quickly. - AnonymousNot applicable
Hello guys,
thanks for prompt response. Unfortunetly your solutions does not resolve my issue. When I use your syntax in Tabular Editor it returns below formatting. I cannot simply create text measure as you do, because I need to reflect it on column chart. Any advice...? 🙂
- vojtechsima
Super User
Anonymous
I am not sure why the percentage doesn't work, you can use pre-defined percentage formating as this:var wyk_p = FORMAT ( MAX(SomethingSomething[Something2]), "Percent")And the rest, try SergioSilvaPT solution for the Condition, implement his logic and my formatting.
- AnonymousNot applicable
It still returns very strange values. Please note the absolute value is incorrect as well... Kamil
- SergioSilvaPT
Resolver V
Anonymous , can you try my solution please to check?
Because you're using to create a calculation groups and there you need the selectedmeasure() function.