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

View all the Fabric Data Days sessions on demand. View schedule

Reply
MuppetyMe
Helper I
Helper I

Stacked bar chart w/dynamic revenue $ measure

I have revenue measure that includes dynamic formatting to provide variable outcomes (K, M, bn): 

VAR salesMeasure = [Revenue]
return
SWITCH(TRUE(),
salesMeasure-1000000000000 && salesMeasure< -1000000000, "$#,,,.0bn",
salesMeasure-1000000000 && salesMeasure< -1000000, "$#,,.0M",
salesMeasure> -1000000 && salesMeasure< -1000,"$#,.0K",
salesMeasure<1000,"$0",
salesMeasure<1000000, "$#,.0K",
salesMeasure<1000000000, "$#,,.0M",
salesMeasure>=1000000000, "$#,,,.0bn")

However, when I add the meausre to the Y-axis of my stacked column chart, the outcomes aren't what I'd expect. Regardless if I choose "None" or "Auto" in Display units, nothing changes. There's a crazy weird mix of K, M, and bn depending on what's going on with my legend parameter selections.

MuppetyMe_0-1763148386995.png

MuppetyMe_2-1763148661609.png

MuppetyMe_1-1763148483484.png

Any thoughts? I fear I may have already found the answer to my question here: Solved: Dynamic Formatting for Y-axis is incorrect for sta... - Microsoft Fabric Community but wanted to check again since that post is over a year old. Thanks in advance for your time! 

EDIT 20-Oct-2025: My concern with the labels in this post is the total labels, not the stacked values. Realized I was not clear on that point in the original post - apoloigies for the confusion. 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @MuppetyMe 

This appears to be a limitation of using a dynamic format string. In the example below, the total should display as around 2M, but instead it shows 2000K. According to the formatting logic, this value should fall under the millions category. A workaround, as suggested by @Idrissshatila , is to use a custom label. Since the total label itself cannot have a custom label, you can disable it, convert the chart to a combo chart, make the line invisible, and then apply the same custom label there. The total label though works fine with table/matrix.

 

danextian_0-1763211268564.png

danextian_1-1763211865416.png

Here's the string I used.

VAR _v = ABS ( [Sales] )   -- replace with your measure
RETURN

SWITCH (
    TRUE(),
    _v = 0,                          "0",
    _v < 1,                          "#.###",        -- e.g. 0.123
    _v < 10,                         "0.##",          -- e.g. 1.2
    _v < 100,                        "0.##",         -- e.g. 12.3
    _v < 1000,                       "0.##0",         -- e.g. 123.45
    _v < 1000000,                    "#,##0,.K",    -- thousands → 1.2K
    _v < 1000000000,                 "#,##0,,.##M",   -- millions  → 1.2M
    _v < 1000000000000,              "#,##0,,,.##Bn", -- billions  → 1.2Bn
    "#,###"                                         -- fallback
)

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
v-karpurapud
Community Support
Community Support

Hi @MuppetyMe 

Thank you for submitting your question to the Microsoft Fabric Community Forum, and thanks to @Idrissshatila and @danextian  offering helpful suggestions.

 

Could you let us know if the suggested solution resolved your issue? If it's still pending, please let us know any further details so we can help.


Best regards,
Community Support Team

 

danextian
Super User
Super User

Hi @MuppetyMe 

This appears to be a limitation of using a dynamic format string. In the example below, the total should display as around 2M, but instead it shows 2000K. According to the formatting logic, this value should fall under the millions category. A workaround, as suggested by @Idrissshatila , is to use a custom label. Since the total label itself cannot have a custom label, you can disable it, convert the chart to a combo chart, make the line invisible, and then apply the same custom label there. The total label though works fine with table/matrix.

 

danextian_0-1763211268564.png

danextian_1-1763211865416.png

Here's the string I used.

VAR _v = ABS ( [Sales] )   -- replace with your measure
RETURN

SWITCH (
    TRUE(),
    _v = 0,                          "0",
    _v < 1,                          "#.###",        -- e.g. 0.123
    _v < 10,                         "0.##",          -- e.g. 1.2
    _v < 100,                        "0.##",         -- e.g. 12.3
    _v < 1000,                       "0.##0",         -- e.g. 123.45
    _v < 1000000,                    "#,##0,.K",    -- thousands → 1.2K
    _v < 1000000000,                 "#,##0,,.##M",   -- millions  → 1.2M
    _v < 1000000000000,              "#,##0,,,.##Bn", -- billions  → 1.2Bn
    "#,###"                                         -- fallback
)

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian and @Idrissshatila, thank you both for your replies and suggestions. While these do solve for the stacked values, I'm unforutnately still struggling to get the total labels to reflect the correct values in K, M, or bn. I've tried converting from a line and stacked column chart to a stacked column chart, but this did not work. My apologies that I was not clear on the totals being the main concern. 

As mentioned in my previous post, the total label text cannot be customized using another measure. Instead, convert your chart to line and column, make the line invisible (100% transparency) and apply the custom label to the line. Make sure their x-axes are aligned.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Second time is the charm - couldn't get it to work yesterday, but gave it another go and this time I got it. Thank you. 

Idrissshatila
Super User
Super User

Hello @MuppetyMe ,

 

so i'll provide you with a solution to apply step by step.

 

first remove the dynamic formatting.

 

just add the stacked chart with the revenue measure as you can see below i replicated the bar

Idrissshatila_0-1763207789822.png

then you create a New Measure as the following 

Revenue (Formatted) = 
VAR salesMeasure = [Revenue]
RETURN
SWITCH(
    TRUE(),
    salesMeasure >= 1000000000,
        FORMAT(salesMeasure / 1000000000, "$0.0") & "bn",
    salesMeasure >= 1000000,
        FORMAT(salesMeasure / 1000000, "$0.0") & "M",
    salesMeasure >= 1000,
        FORMAT(salesMeasure / 1000, "$0") & "K",
    salesMeasure <= -1000000000,
        FORMAT(salesMeasure / 1000000000, "$0.0") & "bn",
    salesMeasure <= -1000000,
        FORMAT(salesMeasure / 1000000, "$0.0") & "M",
    salesMeasure <= -1000,
        FORMAT(salesMeasure / 1000, "$0") & "K",
    FORMAT(salesMeasure, "$0")
)

 

the you go the to formatting of the visual => data labels => values  and replace the revenue with the measure revenue formatted

Idrissshatila_1-1763207905427.pngIdrissshatila_2-1763207920195.pngIdrissshatila_3-1763207948703.pngIdrissshatila_4-1763207962615.png

Idrissshatila_5-1763207994705.png

 

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors