Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
KamilSzpyrka
Helper III
Helper III

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.

 

KamilSzpyrka_1-1653398807015.png

 

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).

KamilSzpyrka_2-1653398960900.png

 

Can anyone advise how I can resolve this? Thanks, Kamil

9 REPLIES 9
KamilSzpyrka
Helper III
Helper III

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...? 🙂 

KamilSzpyrka_0-1653400468715.png

 

@KamilSzpyrka 
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.

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

KamilSzpyrka_1-1653463610295.png

 

@KamilSzpyrka , can you try my solution please to check?

Because you're using to create a calculation groups and there you need the selectedmeasure() function.

Regards,
Sérgio Silva

If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Check out my blog for tips and tricks about Power BI: https://pbibits.wordpress.com/
SergioSilvaPT
Resolver V
Resolver V

Hi @KamilSzpyrka ,

 

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.
Regards,
Sérgio Silva

If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Check out my blog for tips and tricks about Power BI: https://pbibits.wordpress.com/
vojtechsima
Memorable Member
Memorable Member

Hi, @KamilSzpyrka 
Try something like this:

Formatting = 
var wyk = FORMAT ( MAX(SomethingSomething[Something]), "#,###,###.00")
var wyk_p = FORMAT ( MAX(SomethingSomething[Something2]), "##.00%")
return wyk & " / "& wyk_p

vojtechsima_0-1653399554300.png

 

@vojtechsima why you used the MAX function inside the FORMAT?

Regards,
Sérgio Silva

If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Check out my blog for tips and tricks about Power BI: https://pbibits.wordpress.com/

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.

OK, thanks for the explanation!

 

That's the beauty of Power BI and Data Analysis, you don't have one unique solution, you have many that can be used to achieve our requirements! 😊

Regards,
Sérgio Silva

If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Check out my blog for tips and tricks about Power BI: https://pbibits.wordpress.com/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.