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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
bbass82
Helper I
Helper I

Dynamic formatting for negative values

Hello Community friends,

 

Was hoping someone could help me with this issue I am having in regards to dynamic formatting of my values in my DAX. I have some negative values that I want to show in the same format (no negative values in other columns). 

 

I wrote the below DAX in hopes of returning values with the below formatting:

1) Show all negative #'s equal to or greater than -$1,000,000 as formatting of "-$1.0M"

2) Show all negative #'s between -$999,999k to -$0k as formatting of "-$999.9k"

bbass82_0-1738697028089.png

Current State:

bbass82_1-1738697535433.pngbbass82_2-1738697570298.png

 

Any help with this is greatly appreciated. 

 

Kind Regards,

Brandon Bassett

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @bbass82 

I think you just need to add one condition within SWITCH to your current expression to handle negative numbers between -1m and zero.

I would write the overall expression like this with SELECTEDMEASURE assigned to a variable:

 

 

VAR MeasureValue = SELECTEDMEASURE ( )
VAR Result =
    SWITCH (
        TRUE ( ),
        MeasureValue < -1e6, "$#,##0,,.0M",
        MeasureValue < 0, "$#,##0,.0k", -- new condition
        MeasureValue < 1e3, "$#,##0",
        MeasureValue < 1e6, "$#,##0,.0k",
        -- Otherwise >= 1e6
        "$#,##0,,.0M"
    )
RETURN
    Result

 

 

PBIX attached in case that helps debug.

OwenAuger_1-1738706162742.png

You could consider using conditions based on ABS ( SELECTEDMEASURE () ) if the same format string applies to positive/negative values in the same absolute value range.

 

Are you able to get it working at your end?

 

Regards

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @bbass82 

I think you just need to add one condition within SWITCH to your current expression to handle negative numbers between -1m and zero.

I would write the overall expression like this with SELECTEDMEASURE assigned to a variable:

 

 

VAR MeasureValue = SELECTEDMEASURE ( )
VAR Result =
    SWITCH (
        TRUE ( ),
        MeasureValue < -1e6, "$#,##0,,.0M",
        MeasureValue < 0, "$#,##0,.0k", -- new condition
        MeasureValue < 1e3, "$#,##0",
        MeasureValue < 1e6, "$#,##0,.0k",
        -- Otherwise >= 1e6
        "$#,##0,,.0M"
    )
RETURN
    Result

 

 

PBIX attached in case that helps debug.

OwenAuger_1-1738706162742.png

You could consider using conditions based on ABS ( SELECTEDMEASURE () ) if the same format string applies to positive/negative values in the same absolute value range.

 

Are you able to get it working at your end?

 

Regards

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Hi Owen,

 

Thank-you so much for this solution. Worked perfectly for what I was trying to show in my pbix. I am still new to the absolute conditions piece and will be studying up as suggested on how to you utilizate absolutes within my dax. 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.