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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
aledc
New Member

Count based on two columns

ID      Letter
111      A
111      B
111      A
222      B
222      A
333      A
333      A
333      A

I want to create a column that tells you the number of occurrences of A in the ‘Letter’ column for a given ‘ID’. In this example, the count would result in 2 for ID 111, 1 for ID 222 and 3 for ID 333.

 

I’d want a table like this:

ID      Letter      Count of As
111      A            2
111      B            2
111      A            2
222      B            1
222      A            1
333      A            3
333      A            3
333      A            3

 

Thanks for your help

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@aledc , A new column like

countx(filter(table,[ID] = earlier([ID]) && [Letter] = "A"),[ID])

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

1 REPLY 1
amitchandak
Super User
Super User

@aledc , A new column like

countx(filter(table,[ID] = earlier([ID]) && [Letter] = "A"),[ID])

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors