Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

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

  • 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

     

  • 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.
  • Anonymous's avatar
    Anonymous
    Not 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's avatar
      vojtechsima
      Icon for Super User rankSuper 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.

      • Anonymous's avatar
        Anonymous
        Not applicable

        It still returns very strange values. Please note the absolute value is incorrect as well... Kamil

         

    • SergioSilvaPT's avatar
      SergioSilvaPT
      Icon for Resolver V rankResolver 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.