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
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
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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.