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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
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.

Top Solution Authors