excelduplicatesspreadsheetcountiflibreoffice

Using COUNTIF to check for duplicates?


I am using Nextcloud Forms to have students write comments. They use the same form every week, and it all gets put into one big spreadsheet. (There are 101 students.) Because of the simple nature of Nextcloud Forms, I haven't found a way to prevent students from sending duplicate comments, and some students send duplicate comments because they feel unsure that their first attempt went through.

I know how to count the number of comments in total a student has posted using COUNTIF, because that's what I did previously using Google Sheets. (I am trying to rid my life of all things Google.) Previously, I would just use COUNTIF to count the number of times a unique student ID appears, but now I further need to check for duplicate comments. The method that comes to mind is to then check each week's unique "password" that I tell students in the middle of the lecture to make sure people are actually attending the lecture and not popping in five minutes before the end of class to write a bullsh*t comment. Let's say the student ID is 224L023, and the password for this week is "horror." I want to see if there is more than one entry where the student ID field is "224L023" and the password field is "horror." Is there some way to do this using COUNTIF or some other method? I can use LibreOffice, Apple Numbers, or MS Excel for this. (I suppose I could use Google Sheets, too, but that sort of defeats the whole "ridding my life of Google" thing.)


Solution

  • After quickly browsing the Excel documentation, COUNTIFS seems to be what you are looking for. Something like

    =COUNTIFS(A:A, "=id", B:B, "=password")
    

    should do the trick, providing you replace the fields and the cell ranges with the specific ones you need. More documentation on the function with some example usage can be found at: https://support.microsoft.com/en-gb/office/countifs-function-dda3dc6e-f74e-4aee-88bc-aa8c2a866842

    Notice that COUNTIFS is basically a multicriteria version of COUNTIF while being a different function. It works almost the same way, but returns a +1 only if each combination of cells in the line matches the query. You can match a variable too instead of a hardcoded value by using something like:

    =COUNTIFS(A:A, "=id", B:B, "="&C1)
    

    where in this case C1 is the cell where you have saved your weekly password. Notice that if you are using Excel in a different language, you will need to replace the commas and function names as needed.