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
DolEgon22
Advocate II
Advocate II

Hide rows after calculating percent of grand total

This seems like an easy question, but I'm not finding it. 

 

I have a simple set of data that shows RunStatus and Count of Asset. I can get the percent of grand total easily:

 

2017-04-18_10-42-33.png

 

However, all I want to show is the Unknown RunStatus percentage in a simple data label visualization. Unfortunately, if I filter on just Unknown, I get 100%. Is there anyway to simply hide the other rows so that I can only show the Unknown percentage?

 

1 ACCEPTED SOLUTION

Understood, didn't notice the Count of Asset in your screen shot.

 

You should be able to create a measure to do the count and then use it in the same way for % GT.  Something like this:

 

AssetCount = COUNT(Table1[Asset])

 

Then the % GT:

 

% GT = 
VAR CurrAssets = [AssetCount]
RETURN DIVIDE(CurrAssets,CALCULATE([AssetCount],ALL(Table1)))

 

Alternatively, you could add a calculate column, either in your query or in DAX that is simply = 1 and call that AssetCount.  Then you would be summing this column up to get your count per Run Status.

 

Calculated Column:
AssetCount = 1

Measure:
% GT = 
VAR CurrAssets = SUM([AssetCount])
RETURN DIVIDE(CurrAssets,CALCULATE(SUM([AssetCount]),ALL(Table1)))

 

View solution in original post

9 REPLIES 9
bblais
Resolver III
Resolver III

Try using a measure instead of the "Show Value As" function:

 

% GT = 
VAR CurrAssets = SUM(Table1[Asset])
RETURN CALCULATE(DIVIDE(CurrAssets,SUM(Table1[Asset])),ALL(Table1))

This first gets the current row's asset sum, then divides it by the grand total of assets regardless of what filters are applied.


@bblais wrote:

Try using a measure instead of the "Show Value As" function:

 

% GT = 
VAR CurrAssets = SUM(Table1[Asset])
RETURN CALCULATE(DIVIDE(CurrAssets,SUM(Table1[Asset])),ALL(Table1))

This first gets the current row's asset sum, then divides it by the grand total of assets regardless of what filters are applied.


@bblais

No offence, but a little bit mistake in DAX? I guess you mean

% GT =
VAR CurrAssets =
    SUM ( Table1[Asset] )
RETURN
    DIVIDE ( CurrAssets, CALCULATE ( SUM ( Table1[Asset] ), ALL ( Table1 ) ) )

Actually, either formula works, but agreed that the form of yours is cleaner.

Both are great solutions. However, I don't think I was clear on my original post. The Asset column is type 'String', so these measures don't work... I get an error:

 

Calculation error in measure 'Table1'[% GT]: The function SUM takes an argument that evaluates to numbers or dates and cannot work with values of type String.

My intent is to count the # of rows for each asset's "RunStatus" (inherent in PBI and in my screenshot above), and then get a percentage of that count of only 1 of them--in this case, when RunStatus=Unknown. Ultimately, I want to show the Unknown percentage on a Card visualization (which the "Show Value As" function fails me on--when I filter to Unknown, it shows me 100%). 

 

Let me know if that's more clear.

 

Thanks again!

 

Understood, didn't notice the Count of Asset in your screen shot.

 

You should be able to create a measure to do the count and then use it in the same way for % GT.  Something like this:

 

AssetCount = COUNT(Table1[Asset])

 

Then the % GT:

 

% GT = 
VAR CurrAssets = [AssetCount]
RETURN DIVIDE(CurrAssets,CALCULATE([AssetCount],ALL(Table1)))

 

Alternatively, you could add a calculate column, either in your query or in DAX that is simply = 1 and call that AssetCount.  Then you would be summing this column up to get your count per Run Status.

 

Calculated Column:
AssetCount = 1

Measure:
% GT = 
VAR CurrAssets = SUM([AssetCount])
RETURN DIVIDE(CurrAssets,CALCULATE(SUM([AssetCount]),ALL(Table1)))

 

Closer! (sorry I'm a DAX noob) It's showing 1 instead of 100% (and 0 when I filter)... how do I change the value to percentage?

Choose the column you want to format in the fields list on the right, and then go to the modeling tab in the ribbon and change the format to percentage.

...and a PBI noob as well apparently Smiley Indifferent

 

Thanks! I've got what I need!

No problem, happy to help.

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.