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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
PowerBIET
Frequent Visitor

FORMAT function on Negative Numbers

Why are the negative values blank when using my [Revenue Formatted] measure?  I was expecting the FORMAT to convert into a parenthesis (negative number) based on the formats I applied in the SWITCH function.  Please help me resolve. 

 

OneDrive Link to PBIX: SampleProject.pbix

 

Revenue Formatted =
VAR sales = [.Revenue]
VAR result =
SWITCH(TRUE(),
        sales > 1000000,FORMAT(DIVIDE(sales,1000000,0),"$#.#;($#.#)"),
        sales > 100000,FORMAT(ROUND(DIVIDE(sales,1000000,0),3),"$0.###;($0.###)"),
        sales > 10000,FORMAT(ROUND(DIVIDE(sales,100000,0),2),"$0.###;($0.##0)"),
        sales > 1000,FORMAT(ROUND(DIVIDE(sales,10000,0),1),"$#.#00;($#.#00)"),
        sales = 0.00,0
    )
RETURN
result

 

PowerBIET_1-1735402608056.png

 

 

 

 

 

1 ACCEPTED SOLUTION
rajendraongole1
Super User
Super User

Hi @PowerBIET - To handle negative values, you need to add a condition for sales < 0 or rework the logic so negative values fall through to the appropriate FORMAT string. Here's the corrected measure:

 

VAR sales = [.Revenue]
VAR result =
    SWITCH(
        TRUE(),
        sales > 1000000, FORMAT(DIVIDE(sales, 1000000, 0), "$#.#;($#.#)"),
        sales > 100000, FORMAT(ROUND(DIVIDE(sales, 1000000, 0), 3), "$0.###;($0.###)"),
        sales > 10000, FORMAT(ROUND(DIVIDE(sales, 100000, 0), 2), "$0.##0;($0.##0)"),
        sales > 1000, FORMAT(ROUND(DIVIDE(sales, 10000, 0), 1), "$#.#00;($#.#00)"),
        sales = 0, "0",
        sales < 0, FORMAT(sales, "$#,##0.00;($#,##0.00)")
    )
RETURN
 
rajendraongole1_0-1735404728237.png

 

 

Please find the attached pbix FYR





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

Proud to be a Super User!





View solution in original post

1 REPLY 1
rajendraongole1
Super User
Super User

Hi @PowerBIET - To handle negative values, you need to add a condition for sales < 0 or rework the logic so negative values fall through to the appropriate FORMAT string. Here's the corrected measure:

 

VAR sales = [.Revenue]
VAR result =
    SWITCH(
        TRUE(),
        sales > 1000000, FORMAT(DIVIDE(sales, 1000000, 0), "$#.#;($#.#)"),
        sales > 100000, FORMAT(ROUND(DIVIDE(sales, 1000000, 0), 3), "$0.###;($0.###)"),
        sales > 10000, FORMAT(ROUND(DIVIDE(sales, 100000, 0), 2), "$0.##0;($0.##0)"),
        sales > 1000, FORMAT(ROUND(DIVIDE(sales, 10000, 0), 1), "$#.#00;($#.#00)"),
        sales = 0, "0",
        sales < 0, FORMAT(sales, "$#,##0.00;($#,##0.00)")
    )
RETURN
 
rajendraongole1_0-1735404728237.png

 

 

Please find the attached pbix FYR





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

Proud to be a Super User!





Helpful resources

Announcements
Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.