Stuck on how to continue with CountIf

SB 40 Reputation points
2025-12-11T18:59:01.53+00:00

I want to use the CountIf function to count the "badge tagged" (column B) but limit it to count the total number of times each type of badge is listed for each unique student ID (column A). So I can easily apply the formula to a huge data set.

Anyone have any suggestions?

User's image

Microsoft 365 and Office | Excel | For education | Windows
0 comments No comments
{count} votes

Answer accepted by question author
  1. Ashish Mathur 100.9K Reputation points Volunteer Moderator
    2025-12-11T23:19:40.81+00:00

    Hi,

    Select the data and go to Insert > Pivot Table. Check the box of "Add this data to the Data Model". Click on OK. Drag Student_ID to the row labels and badge_tagged to the value area. Right click on any number in the Pivot Table. Under Summarize by, select Distinct Count.

    1 person found this answer helpful.
    0 comments No comments

Answer accepted by question author
  1. Marcin Policht 68,850 Reputation points MVP Volunteer Moderator
    2025-12-11T19:15:07.9+00:00

    To count how many times each badge appears per unique student ID, you can use a COUNTIFS formula that checks both the student ID in column A and the badge type in column B. This lets you drag the formula down a large dataset without manually filtering anything.

    If your StudentID is in A2 and the Badge_Tagged value is in B2, place this formula in a new column (for example C2). It counts how many times that same badge appears for that same student: =COUNTIFS($A:$A,A2,$B:$B,B2)

    If you want each student-badge combination to display the total only once (for example, only on the first occurrence), add a condition that checks whether the current row is the first matching instance: =IF(COUNTIFS($A$2:A2,A2,$B$2:B2,B2)=1,COUNTIFS($A:$A,A2,$B:$B,B2),"")

    This will return the total count the first time the student-badge pair appears and leave later duplicate rows blank.


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.