cancel
Showing results for
Did you mean:
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.

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
1 ACCEPTED SOLUTION

Accepted Solutions
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,
" "
)```
5 REPLIES 5
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

Proud to be a Datanaut!

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

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

## 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,
" "
)```
Frequent Visitor

## Re: Grand total with Blank vaue

Hi

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

Announcements