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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
lightw0rks
Frequent Visitor

Count instances where ID occurs less than N times in column

I have data similar to the following:

 

IDDate
A01/01/2020
A02/01/2020
A03/01/2020
B04/01/2020
B05/01/2020
C06/01/2020

 

How can I count the number of instances a unique ID appears less than 3 times.

 

E.g. both B and C occur less than 3 times in the ID column, A does not, so the expected result would be '2'.

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@lightw0rks , Try a measure like

Measure =
var _instance =3
return
countx(filter(summarize(Table,table[ID],"_1" ,count(table[Date])),[_1]<_instance),[ID])

 

_instance can come from a what if parameter

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

harshnathani
Community Champion
Community Champion

Hi @lightw0rks ,

 

Try this measure

 

Measure 3 = 

var _table = 

SUMMARIZE('Table','Table'[ID], "_1", COUNTA('Table'[ID]))
RETURN
COUNTROWS(FILTER(_table, [_1] >=2))

 

 

1.jpg

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

View solution in original post

3 REPLIES 3
lightw0rks
Frequent Visitor

Thanks guys, both those solutions work!

harshnathani
Community Champion
Community Champion

Hi @lightw0rks ,

 

Try this measure

 

Measure 3 = 

var _table = 

SUMMARIZE('Table','Table'[ID], "_1", COUNTA('Table'[ID]))
RETURN
COUNTROWS(FILTER(_table, [_1] >=2))

 

 

1.jpg

 

Regards,
Harsh Nathani
Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

amitchandak
Super User
Super User

@lightw0rks , Try a measure like

Measure =
var _instance =3
return
countx(filter(summarize(Table,table[ID],"_1" ,count(table[Date])),[_1]<_instance),[ID])

 

_instance can come from a what if parameter

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.