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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
peterg0417
Helper II
Helper II

Can't get negative basis points in parentheses to show properly

Just got a request from leadership to change the way our basis points are displayed. A third party vendor created this model and I'm tasked with managing it going forward.

Here is the DAX formula they created:

 

YTD Growth =
VAR FormatToUse =
    IF (
        SELECTEDVALUE ( 'Key Statistics'[Key Statistic] ) = "NAV",
        "0.0%;(0.0%);-",
        "0bps"
    )
RETURN
    IF (
        OR ( [YTD Growth Number KS] = 0, ISBLANK ( [YTD Growth Number KS] ) ),
        "-",
        FORMAT (
            [YTD Growth Number KS]
                * IF ( FormatToUse  = "0bps", 10000, 1 ),
            FormatToUse
        )
    )
 
The result of this query is:
peterg0417_3-1668700128453.png
 
When it's a percentage, the it displays the correct format. Eg. (55.5%) for a negative 55%. But for basis points (bps) I can't get it to work when I try modifying the variable to this:
VAR FormatToUse =
    IF (
        SELECTEDVALUE ( 'Key Statistics'[Key Statistic] ) = "NAV",
        "0.0%;(0.0%);-",
        "0bps;(0bps)"
    )
RETURN
 
Then modify the IF statement further on:
IF (
        OR ( [YTD Growth Number KS] = 0, ISBLANK ( [YTD Growth Number KS] ) ),
        "-",
        FORMAT (
            [YTD Growth Number KS]
                * IF ( FormatToUse IN { "0bps", "(0bps)"}, 10000, 1 ),
            FormatToUse
        )
    )
 
The result I get is this:
peterg0417_2-1668699905370.png

 


The expected result where it's highlighted is (10,000bps) and (8,182bps). For some reason, in the IF statement, it's not recognizing the negatives, and it's just multiplying by 1, as opposed to 10000 like it's supposed to do.

 

Any ideas on how to get this to work?

 

Thx

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@peterg0417 Should be this: 

 * IF ( FormatToUse IN { "0bps;(0bps)"}, 10000, 1 ),

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Rushki
Regular Visitor

Hi @peterg0417 ,
Try modifying your IF statement as below: 

IF (
        OR ( [YTD Growth Number KS] = 0ISBLANK ( [YTD Growth Number KS] ) ),
        "-",
        FORMAT (
            [YTD Growth Number KS]
                * IF ( FormatToUse ="0bps;(0bps)"100001 ),
            FormatToUse
        )
    )
Greg_Deckler
Super User
Super User

@peterg0417 Should be this: 

 * IF ( FormatToUse IN { "0bps;(0bps)"}, 10000, 1 ),

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Ahh yes, that makes sense

 

This whole custom formatting is very new to me so thank you for the quick solution

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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