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

Count number of specific categories

Hi, 


If I have the dataset below and want to find out the amount of categories with 2 or less IDs belonging, how do I do this. 
I have found the total amount of categories (in this example, num_cat = 4), but I struggle to find the number of categories with 2 or less IDs connected to it.

 

Num_cat_less_than_2 = 2 because only category C and D has less than 2 IDs connected to them. 

 

jak123_1-1628519528431.png

 

 

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Picture1.png

 

Num_Cat_Less_Than_2 : =
COUNTROWS (
FILTER (
ADDCOLUMNS (
VALUES ( 'Table'[Category] ),
"idcount", CALCULATE ( COUNTROWS ( 'Table' ) )
),
[idcount] < 2
)
)

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

You can add both your column in table visual and take distinct of your ID column 

Samarth_18_0-1628520990260.png

 

and now select filter as below:-

Samarth_18_1-1628521075150.png

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

Thank you! I forgot to specify that I need to formulate this in DAX, not as a visualization. 

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.