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
splambo
Advocate I
Advocate I

How to dynamically format numbers, currency and abbreviation ($K, $M, $B) in Detail Labels?

dynamic number formatting for visuals detail labels.png

My requires that I show numbers as  ## $K, and my data column for a chart has numbers in the thousands, millions and billions.

 

Chart visuals require numbers in order to show detail labels, but the only way I know to dynamically format numbers creates text that cannot be used as a label.

 

The Format pane options for Detail Labels gives an fx field for color, but not for Display Units or Decimal Places.

 

For example, I need the detail labels on this visual to show 1.25 $B with two decimals when equal to or above to a billion, and 820 $M without decimals when below a billion. I can handle the creation of formulas, but there doesn't seem to be a way to enter those formulas anywhere. Help!

1 ACCEPTED SOLUTION

Hi @splambo  I suggest that you follow my steps in order to ensure that you performed the same actions.
Also attached is an example I made.
1. 

Ritaf1983_0-1684289139553.png

2. Just calculate your measure as you need.

Ritaf1983_1-1684289297819.png

 

3. Modify your format changes based on this measure:

Ritaf1983_2-1684289382768.png

Dax code:

SWITCH(
    true(),
    SELECTEDMEASURE()>999999999,"$#,##0,,,.0B",
    SELECTEDMEASURE()>999999,"$#,##0,,.0M",
    SELECTEDMEASURE()>999,"$#,##0,.00K","$#,##0.0")

4. Put it on your chart and pay attention to that "display units" is "none" on format options of value:

Ritaf1983_3-1684289608362.png

 

Result :

Link to the sample file 

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
splambo
Advocate I
Advocate I

I got an updated powerbi version and am using the dynamic format to format string measures and it simply seems buggy.

I'm trying to format millions to a shortened format such as $8.9M but the output in the chart's detail labels is inconsistent (and wonky!);

 

Data               Desired result          Actual result
8,999,274         $8.9M                     $9.0M
13,156,240       $13.2M                   $132M
20,271,133       $20.3M                   $2202711333M


My Measure formula is:

Measure = MAX(table[column])

 

My format formula is:

VAR Tot = MAX('table'[column])
RETURN FORMAT(Tot/1000000, "$#,##0.0M")

{65656550-DD3F-4A49-B42D-06C145D34D2A}.png

Hi @splambo  I suggest that you follow my steps in order to ensure that you performed the same actions.
Also attached is an example I made.
1. 

Ritaf1983_0-1684289139553.png

2. Just calculate your measure as you need.

Ritaf1983_1-1684289297819.png

 

3. Modify your format changes based on this measure:

Ritaf1983_2-1684289382768.png

Dax code:

SWITCH(
    true(),
    SELECTEDMEASURE()>999999999,"$#,##0,,,.0B",
    SELECTEDMEASURE()>999999,"$#,##0,,.0M",
    SELECTEDMEASURE()>999,"$#,##0,.00K","$#,##0.0")

4. Put it on your chart and pay attention to that "display units" is "none" on format options of value:

Ritaf1983_3-1684289608362.png

 

Result :

Link to the sample file 

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

splambo
Advocate I
Advocate I

Thank you @Ritaf1983 !
The article mentions this feature is available with PBI Desktop version 2.116.622.0 or later. I have requested this version to my employer and will report back as soon as I can try the solution.

Ritaf1983
Super User
Super User

Hi @splambo 
From the April version of the desktop, you have this option generically .

please refer to this tutorial:
https://datasavvy.me/2023/04/21/how-to-use-the-new-dynamic-format-strings-for-measures-in-power-bi/

 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.


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.