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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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