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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
r-ramillien
Regular Visitor

Display how many companies have how many categories

Dear powerBI community,

 

I have a simple table like below:

___________________________________________________________

Company (string)    | Category (string)  | Other column 

___________________________________________________________

Co_A                       | Cat_1                     | A

Co_A                       | Cat_1                     | B

Co_A                       | Cat_2                     | C

Co_A                       | Cat_2                     | D

Co_B                       | Cat_2                     | E

Co_B                       | Cat_3                     | F

Co_B                       | Cat_3                     | G

Co_C                       | Cat_3                     | H

Co_C                       | Cat_2                     | I

Co_C                       | Cat_1                     | J

Co_D                       | Cat_1                     | K

 

I would like to display a cluster bar and a pie chart which shows how many companies have how many distinct categories.

For example

2 Companies have 2 Categories (because Co_A have Cat_1 and Cat_2 and Co_B have Cat_2 and Cat_3)

1 Company have 3 categories (because Co_D have Cat_1, Cat_2 and Cat_3)

 

I'm sure its pretty straightfoward for many of you, but I can't find a way to do it. I tried to create few custom measures, but I can't add them to the "legend" or "axis" of the chart 😞

 

Thank you for your help ! 🙂

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@r-ramillien One way, create an Axis table: 

Axis = GENERATESERIES(1,100,1)
 
The a measure: 
Measure =
VAR __AxisValue = MAX('Axis'[Value])
VAR __Table = SUMMARIZE('Table',[Company],"__Cat",COUNTROWS(DISTINCT('Table'[Category])))
RETURN
COUNTROWS(FILTER(__Table,[__Cat] = __AxisValue))
 
PBIX file is attached below sig.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@r-ramillien One way, create an Axis table: 

Axis = GENERATESERIES(1,100,1)
 
The a measure: 
Measure =
VAR __AxisValue = MAX('Axis'[Value])
VAR __Table = SUMMARIZE('Table',[Company],"__Cat",COUNTROWS(DISTINCT('Table'[Category])))
RETURN
COUNTROWS(FILTER(__Table,[__Cat] = __AxisValue))
 
PBIX file is attached below sig.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hello,

 

Thank you, it work great !
I still have to understand how it works, but it works 🙂

 

Sorry, I cannot accept the answer right now, there is a problem with my account bound with the one of microsoft 365...

 

Best regards

amitchandak
Super User
Super User

@r-ramillien , to me it seems like

distinctcount(Table[Category]) with Company as legend in pie

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you for your response,

 

You're right about the distinct count, but my problem is more with the legend.

I need to have the number of companies with a specific number of categories, not the name of the company itself.

 

Best regards

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.