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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Dynamic format for measure on column/bar chart

I've been trying to set dynamic format for measure on bar/column chart, but when data labels' display units is set to "none", Power BI ignores my dynamic format UNLESS I set decimal places to > 0 – then it works. However, I don't want those decimal places. Weird thing is that in "Show as a table" view it works all the time.

wojpie11_0-1684336200540.pngwojpie11_1-1684336244605.png


Also, here is the code for measure format:

VAR __AbsVal = ABS(SELECTEDMEASURE())
RETURN
SWITCH(
    TRUE(),
    __AbsVal < 1000, "#,0",
    __AbsVal < 1000000, "#,0,.K",
    __AbsVal < 1000000000, "#,0,,.M",
    "#,0,,,.B"
    )
4 REPLIES 4
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Anonymous
Not applicable

Here is the sample data:

CustomerSales
Customer 1123
Customer 212345
Customer 31234567

 

Here is the sample measure:

 

Sum of Sales = 
SUM('Table'[Sales])

 

 

Here is the format string for the measure:

 

VAR __AbsVal = ABS(SELECTEDMEASURE())
RETURN
SWITCH(
    TRUE(),
    __AbsVal < 1000, "#,0",
    __AbsVal < 1000000, "#,0,.K",
    __AbsVal < 1000000000, "#,0,,.M",
    "#,0,,,.B"
)

 

 

This is what I expect:

wojpie11_0-1684742788919.png


This is what I see on the bar chart:

wojpie11_1-1684742855393.png

 

 

SWITCH(
    TRUE(),
    SELECTEDMEASURE() < 1000, "#",
    SELECTEDMEASURE() < 1000000, "#,##0,.0 K",
    SELECTEDMEASURE() < 1000000000, "#,##0,,.0 M",
    "#,##0,,,.0 B"
)

 

this should get you closer.  Still has one decimal, but I'm sure they will address this bug soon:  Dynamic Format Strings Bug - Microsoft Power BI Community

Anonymous
Not applicable

I know it is a bug, that is why I originally posted this in the "Issues" forum, but somebody moved it here, without any notice.

I also know adding one decimal place helps (as I mentioned in my first post), but I would like to be able to set a dynamic format to 0 decimal places and use it on bar/column chart. As for now it's just not possible.

Nevertheless, thank you for trying to help, much appreciated.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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