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

---------------------------------------

Not the Power BI thought police...

##### I have NEW book! DAX Cookbook from Packt
Over 120 DAX Recipes!

Proud to be a Datanaut!

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

## 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

#### New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

#### ‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

#### Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

#### Join THE global Power Platform event series.

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities.

#### Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors