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
nsaleh
Frequent Visitor

Grand total with Blank vaue

Hi,

 

I have a matrix table, i used a measure column using Swtich function to get some data. Bi Error.PNG

i used a measure column to get W/L ration as below: 

 

Ratio = SWITCH(SELECTEDVALUE(closed[Outcome]),
"1. Won", (divide(CALCULATE(COUNT(Closed[Outcome]),Closed[Outcome]="1. Won"), (CALCULATE(COUNT(Closed[Outcome]),Closed[Outcome]="1. Won") +CALCULATE(COUNT(Closed[Outcome]),Closed[Outcome]="2. Lost")),0)*100) ," ")
 
so i have a problem that i cant see the grand total for W/L ration becouse of the blank value in some rows. please help to get grand total for W/L Ratio and keep the blank Values.
 
Thank you
Nad
1 ACCEPTED SOLUTION

The problem here is that SELECTEDVALUE() will return a value if there is a single value for Closed[Outcome] and at the "Total" level you don't have a single value (you technically have all values).

 

So I think changing the code to something like the following (using a variable to avoid copying the calculation logic twice) should fix this for you.

Ratio =
VAR _pcntWon = (
        DIVIDE (
            CALCULATE ( COUNT ( Closed[Outcome] ), Closed[Outcome] = "1. Won" ),
            (
                CALCULATE ( COUNT ( Closed[Outcome] ), Closed[Outcome] = "1. Won" )
                    + CALCULATE ( COUNT ( Closed[Outcome] ), Closed[Outcome] = "2. Lost" )
            ),
            0
        ) * 100
    
RETURN SWITCH (
    SELECTEDVALUE ( closed[Outcome], "Total" ),
    "1. Won", _pcntWon,
    "Total", _pcntWon,
    " "
)

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907


@ 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...

Hi Greg,

 

Thank you for your reply. i go througth the links you sent, but there are some rows sholud be Balnk and i will have same issue. Please what shall i write in the measure column to solve the issue.

 

Thank you Again.

 

Nad

HI @nsaleh,

 

If you can please share a pbix file with part of sample data for test. It should be help for testing and coding formula.
BTW, I'm not so recommend you to use switch function to handle with summarize records. It not suitable for split summarize records to multiple part.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

The problem here is that SELECTEDVALUE() will return a value if there is a single value for Closed[Outcome] and at the "Total" level you don't have a single value (you technically have all values).

 

So I think changing the code to something like the following (using a variable to avoid copying the calculation logic twice) should fix this for you.

Ratio =
VAR _pcntWon = (
        DIVIDE (
            CALCULATE ( COUNT ( Closed[Outcome] ), Closed[Outcome] = "1. Won" ),
            (
                CALCULATE ( COUNT ( Closed[Outcome] ), Closed[Outcome] = "1. Won" )
                    + CALCULATE ( COUNT ( Closed[Outcome] ), Closed[Outcome] = "2. Lost" )
            ),
            0
        ) * 100
    
RETURN SWITCH (
    SELECTEDVALUE ( closed[Outcome], "Total" ),
    "1. Won", _pcntWon,
    "Total", _pcntWon,
    " "
)

Hi 

 

Its working fine now. Thank you so much for your help.

 

Nad

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.