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
AndrewKent
Helper I
Helper I

Countif (or equivalent) Per Row in PowerQuery/Dax

Hi,

 

Apologies but although I can see several topics on this, I'm not sure how they fit to my specific issue. I have one table of data that I am modelling. The table contains records assessment attempts for staff. There are multiple rows for individuals. What I want to do is:

 

- In a new column [Attempts], carry out a countif on a column [Staff ID] for each row in the table (the Excel equivalent would be =COUNTIF([STAFF ID],A1) for each row.

 

- Remove duplicate rows in [Staff ID]

 

This should leave me with 1 record per staff member with an aggregated amount of of attempts in the [Attempts] column

 

Hope this makes sense.

 

Andy

1 ACCEPTED SOLUTION

Hi Andy

 

Doing a Groupby can solve your problem. See the attached screenshot.GROUPBYGROUPBY

EXPECTED OUTPUTEXPECTED OUTPUT

 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

View solution in original post

7 REPLIES 7
hadiahadi
New Member

hadiahadi
New Member

BhaveshPatel
Community Champion
Community Champion

I think You can fit Conditional column and Groupby in this scenario. 

Sample data would give me a kick start to work with your problem.

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Hi,

 

The data set really is as simple as the first data set is the original data, and using Power Query I want to model it to look like the second table if that makes sense.

 

Andy

Number of Attempts.PNG

hi,

 

I am looking for countif to work same as it work in excel. so, each row would have distinct count

sgoyal_0-1632975175060.png

sgoyal_1-1632975233891.png

I am new to power query pls help in how to add column and add function. 

Thanks in advance

 

  

Hi Andy

 

Doing a Groupby can solve your problem. See the attached screenshot.GROUPBYGROUPBY

EXPECTED OUTPUTEXPECTED OUTPUT

 

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

Perfect! Exactly what I was after.

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.