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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
aloosh89
Helper I
Helper I

Counting occurence of attribute only once per ID

Hello,

 

I have the below sample dataset. I am trying to create a measure which gives the occurence of the attribute A but I only want A's occurence to be counted once per ID value.

 

For the sample dataset the measure should return a count of 3 (Once from ID=1, Once from ID=3 and Once from ID=4).

 

Any help would be much appreciated.

 

IDAttribute
1A
1A
1B
2B
2B
3A
3A
3C
4A

 

Thanks,

Ali 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Write these measures

A count = CALCULATE(COUNTROWS(Data),Data[Attribute]="A")
Measure = COUNTROWS(FILTER(VALUES(Data[ID]),[A count]>0))

Hope this helps.

Ashish_Mathur_0-1693797888624.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Write these measures

A count = CALCULATE(COUNTROWS(Data),Data[Attribute]="A")
Measure = COUNTROWS(FILTER(VALUES(Data[ID]),[A count]>0))

Hope this helps.

Ashish_Mathur_0-1693797888624.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

This worked, thanks @Ashish_Mathur 

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
danextian
Super User
Super User

hi @aloosh89 ,

 

Are you trying to count the occurence fo each item in ID just once. If  so, try this measure:

Count =
COUNTROWS ( SUMMARIZE ( 'Table', 'Table'[ID], 'Table'[Attribute] ) )

danextian_0-1693794795647.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ahmedx
Super User
Super User

Is this what you are looking for?

Sample PBIX file attached

Counting occurence of attribute only once per ID.pbix

 

Screenshot_1.png

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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