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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ashwinkolte
Helper III
Helper III

Dynamic formatting - Negative number showing brackets as well as negative sign

Hi 

 

I am using dynamic formatting string for a measure which has  positive and negetive numbers .I want the negetive numbers to be displayed in brackets instead of the negetive sign (-) . With the below code, for negetive numbers , brackets as well as negetive sign is getting displayed dsiplayed. How to get rid of this negetive sign for numbers which are already in brackets 

Code :

 

var result =
SWITCH(
       TRUE(),
       [M_Profit/Loss] >= 10000000 , "₹ "& ROUND(DIVIDE([M_Profit/Loss],10000000),2) & "Cr",
       [M_Profit/Loss] >= 100000 , "₹ "& ROUND(DIVIDE([M_Profit/Loss],100000),1) & "L",
        "₹ "& FORMAT([M_Profit/Loss],"#,#;(#,#);-")
     )
RETURN """" & result

 

Result for the measure : (showing brackets as well as negetive sign for negetive numbers 😞 

 

ashwinkolte_0-1718461906195.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ashwinkolte ,

 

Thanks for the reply from Ritaf1983 .

 

You can't do what you want because you don't have a "-".

 

Here's an alternative:

 

You can create a measure:

Sort =
VAR _vtable =
    ADDCOLUMNS (
        SUMMARIZE (
            ALLSELECTED ( 'Table' ),
            'Table'[category],
            "_Sum", [sum_],
            "_sum2", [MEASURE]
        ),
        "Sort",
            RANKX (
                SUMMARIZE (
                    ALLSELECTED ( 'Table' ),
                    'Table'[category],
                    "_Sum", [sum_],
                    "_sum2", [MEASURE]
                ),
                [_Sum],
                ,
                DESC
            )
    )
RETURN
    MAXX (
        FILTER ( _vtable, [category] = SELECTEDVALUE ( 'Table'[category] ) ),
        [Sort]
    )

 

Sort sort to see the correct sorting.

vhuijieymsft_0-1719565069895.png

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @ashwinkolte ,

 

Thanks for the reply from Ritaf1983 .

 

Here is the sample data I created:

Column1

17,297

13,841

11,904

8,639

6,715

3,431

2,718

-9,772

-11,493

-13,287

-17,087

-24,449

 

Create a measure:

MEASURE = 
SWITCH (
    TRUE (),
    MAX ( 'Table'[Column1] ) >= 10000000, ROUND ( DIVIDE ( MAX ( 'Table'[Column1] ), 10000000 ), 2 ) & "Cr",
    MAX ( 'Table'[Column1] ) >= 100000, ROUND ( DIVIDE ( MAX ( 'Table'[Column1] ), 100000 ), 1 ) & "L",
    IF (
        MAX ( 'Table'[Column1] ) < 0,
        "-₹" & FORMAT ( MAX ( 'Table'[Column1] ), "#,0.00;(#,0.00);0" ),
        "₹" & FORMAT ( MAX ( 'Table'[Column1] ), "#,0.00;(#,0.00);0" )
    )
)

 

The final page visual effect is as follows:

vhuijieymsft_0-1718593462884.png

 

If you have any other questions please feel free to contact me.

 

The pbix file is attached.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Hi @Anonymous 

 

Thank you so much for your response, however with the solution you provided, negetive numbers are still showing brackets as well as negetive sign . If the negetive numbers are already in brackets , then there should not be negetive sign . How can we get rid of the negetive sign? . This is infact the actual problem 

Hi @ashwinkolte 
You can modify the formula of @Anonymous  to 

MEASURE =
SWITCH (
    TRUE (),
    MAX ( 'Table'[Column1] ) >= 10000000, ROUND ( DIVIDE ( MAX ( 'Table'[Column1] ), 10000000 ), 2 ) & "Cr",
    MAX ( 'Table'[Column1] ) >= 100000, ROUND ( DIVIDE ( MAX ( 'Table'[Column1] ), 100000 ), 1 ) & "L",
    IF (
        MAX ( 'Table'[Column1] ) < 0,
        "₹" & FORMAT ( MAX ( 'Table'[Column1] ), "#,0.00;(#,0.00);0" ),
        "₹" & FORMAT ( MAX ( 'Table'[Column1] ), "#,0.00;(#,0.00);0" )
    )
)
Result:
Ritaf1983_0-1718609733688.png

Modified file is attached :

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Dear @Ritaf1983  Thanks for quick reply. However please note I am trying to format a measure and not a table column . is this the problem ? . Also cant use MAX for the measure. But I tried the format you gave . Its still not working  

 

ashwinkolte_0-1718612493960.png

 

var result =

SWITCH(
       TRUE(),
       [M_Profit/Loss] >= 10000000 , "₹ "& ROUND(DIVIDE([M_Profit/Loss],10000000),2) & "Cr",
       [M_Profit/Loss] >= 100000 , "₹ "& ROUND(DIVIDE([M_Profit/Loss],100000),1) & "L",
       -- "₹ "& FORMAT([M_Profit/Loss],"#,#;(#,#);-")
       IF( [M_Profit/Loss] < 0 ,
                                "₹" & FORMAT ([M_Profit/Loss], "#,0.00;(#,0.00);0" ),
                                "₹" & FORMAT ([M_Profit/Loss], "#,0.00;(#,0.00);0" )
                                )
          )
         
RETURN """" & result

Hi @ashwinkolte 
It works with the measure too :

Ritaf1983_0-1718614318244.png

Try to follow the steps according to updated pbix

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi @Ritaf1983  Thank you for the response. yes it did work with measure as well but now there is  another problem. Now the measure is converted into string and hence it wont sort correctly as a number . See below the screenshots after sorting the  measure as well as the orignal number . Hence I was trying to use dynamically formatted strings where it will still retain its numerical nature even if apended with string like "Cr" , "L" or simply any other formatting , and hence sort correctly  . While using dynamically formatted strings  I was getting this issue of negetive sign with bracket. , which I sent originally 

 

ashwinkolte_0-1718621570160.png

ashwinkolte_1-1718621619976.png

 

 

 

 

Anonymous
Not applicable

Hi @ashwinkolte ,

 

Thanks for the reply from Ritaf1983 .

 

You can't do what you want because you don't have a "-".

 

Here's an alternative:

 

You can create a measure:

Sort =
VAR _vtable =
    ADDCOLUMNS (
        SUMMARIZE (
            ALLSELECTED ( 'Table' ),
            'Table'[category],
            "_Sum", [sum_],
            "_sum2", [MEASURE]
        ),
        "Sort",
            RANKX (
                SUMMARIZE (
                    ALLSELECTED ( 'Table' ),
                    'Table'[category],
                    "_Sum", [sum_],
                    "_sum2", [MEASURE]
                ),
                [_Sum],
                ,
                DESC
            )
    )
RETURN
    MAXX (
        FILTER ( _vtable, [category] = SELECTEDVALUE ( 'Table'[category] ) ),
        [Sort]
    )

 

Sort sort to see the correct sorting.

vhuijieymsft_0-1719565069895.png

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Ritaf1983
Super User
Super User

Hi @ashwinkolte 
Modify the format part for :
"#,##;(#,##)"

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

 


Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors