cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nsaleh Frequent Visitor
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

Accepted Solutions
Super User III
Super User III

Re: Grand total with Blank vaue

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
Super User IV
Super User IV

Re: Grand total with Blank vaue

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


I have book! Learn Power BI from Packt


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

Proud to be a Datanaut!

Highlighted
nsaleh Frequent Visitor
Frequent Visitor

Re: Grand total with Blank vaue

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

Community Support Team
Community Support Team

Re: Grand total with Blank vaue

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 Sheng
If this post helps, please consider Accept it as the solution to help the other members find it more quickly
Learning resources: Power BI
Super User III
Super User III

Re: Grand total with Blank vaue

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

nsaleh Frequent Visitor
Frequent Visitor

Re: Grand total with Blank vaue

Hi 

 

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

 

Nad

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

January 2020 Community Highlights

January 2020 Community Highlights

Make sure you didn't miss any of the things that happened in the community in January!

Top Solution Authors
Top Kudoed Authors