Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
PowerBI__
Frequent Visitor

Category count percentage by dividng it with total count of category column also based on slicers

Hello,
I have got a below data:

CountryCompanyCategory
XABA
ZACA
YADB
YABC
XADB
ZABA
XACB
XABC
YACA
ZABA

I was using below measure CategoryPercentage =
DIVIDE(
COUNT('YourTable'[Category]),
CALCULATE(COUNT('YourTable'[Category]), ALL('YourTable')),
0
)
to get the % but the when I use slicer of country or company the numerator gets slicer but due to ALL function demominator count of category remains same which makes category in that country divided by again total count of column rather then sliced by country slicer. I want if I do not select slicer then each category divide by total column count. But if I select slicer of country then each category available in that country divde by the category column count which was in that country. 
Basically I was looking to see only top 5 Categories % as all or once they are sliced by slicer of country and company.
Your hel would be highly appreciated.
Thank you

1 ACCEPTED SOLUTION
shafiz_p
Super User
Super User

Hi @PowerBI__  Try this:

CategoryPercentage = 
DIVIDE(
    COUNT('YourTable'[Category]),
    CALCULATE(
        COUNT('YourTable'[Category]),
        REMOVEFILTERS('YourTable'[Category])
    ),
    0
)

 

 

Top 5 Categories

To show only the top 5 categories by percentage, you can use a visual-level filter:

  1. Add a table or matrix visual.
  2. Add the Category and CategoryPercentage fields.
  3. Apply a visual-level filter to CategoryPercentage to show the top 5 items.

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

View solution in original post

1 REPLY 1
shafiz_p
Super User
Super User

Hi @PowerBI__  Try this:

CategoryPercentage = 
DIVIDE(
    COUNT('YourTable'[Category]),
    CALCULATE(
        COUNT('YourTable'[Category]),
        REMOVEFILTERS('YourTable'[Category])
    ),
    0
)

 

 

Top 5 Categories

To show only the top 5 categories by percentage, you can use a visual-level filter:

  1. Add a table or matrix visual.
  2. Add the Category and CategoryPercentage fields.
  3. Apply a visual-level filter to CategoryPercentage to show the top 5 items.

 

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

Best Regards,
Shahariar Hafiz

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.