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
Anonymous
Not applicable

How to get percentage of total rows when grouping by a column?

I have the below table:

Person

Inventory

A

Red

B

Red

A

Blue

A

Yellow

B

Blue

C

Yellow

 

I have a report that allows me to filter by 'Person'. When I select a 'Person', I would like a Card to display the percentage of total inventory that 'Person' has.

 

For example, when 'A' is selected it would show 50%, when 'B' is selected it would show 67%, etc.

 

How would I go about doing this?

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

This Measure should do it

Measure =
DIVIDE (
    COUNTA ( 'Table'[Inventory] ),
    CALCULATE ( COUNTA ( 'Table'[Inventory] ), ALL ( 'Table' ) ),
    0
)

View solution in original post

3 REPLIES 3
v-ljerr-msft
Employee
Employee

Hi @Anonymous,

 

Have you tried the solution provided above? Does it work in your scenario? If the solution works, could you accept it as solution to close this thread?

 

If you still have any question on this issue, feel free to post here. Smiley Happy

 

Regards

Sean
Community Champion
Community Champion

This Measure should do it

Measure =
DIVIDE (
    COUNTA ( 'Table'[Inventory] ),
    CALCULATE ( COUNTA ( 'Table'[Inventory] ), ALL ( 'Table' ) ),
    0
)
Anonymous
Not applicable

Perfect, it looks like that works. 

 

I had been using this which was working:

Measure = COUNTROWS('Table') / COUNTROWS( ALL('Table') )

 

Yours does the trick too. Thanks for the 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.