momogabi

Q: How do I count unique entries across multiple columns?

I am trying to calculate the total number of unique individuals who attend an after-school program during a given week. Here is what my table looks like:

 

Screenshot 2016-09-09 09.08.43.png

 

Calculating the total attendance each day and week is no problem. But how do I calculate the number of unique people who attended at least once during the week?

 

By the way, Y means that yes, they attended that day. If there is a better way to note this, I'm all ears.

 

Thanks for any help you can provide.

OS X Yosemite (10.10.4), Numbers 3.5.3

Posted on Sep 9, 2016 9:19 AM

Close

Q: How do I count unique entries across multiple columns?

  • All replies
  • Helpful answers

  • by t quinn,

    t quinn t quinn Sep 9, 2016 7:31 PM in response to momogabi
    Level 5 (5,012 points)
    Mac OS X
    Sep 9, 2016 7:31 PM in response to momogabi

    Hi momogabi,

     

    Here is an approach that uses an additional column.

    Screen Shot 2016-09-09 at 8.21.23 PM.png

    COUNTA returns the number of its arguments that are not empty.

    Screen Shot 2016-09-09 at 8.26.33 PM.png

    I put the count of unique students in the footer. it could be anywhere.

     

    If you decide checkboxes are easier than "Y" Use COUNTIF() for both functions.

    Screen Shot 2016-09-09 at 8.28.31 PM.png

     

    quinn

  • by SGIII,

    SGIII SGIII Sep 9, 2016 9:12 PM in response to momogabi
    Level 6 (10,647 points)
    Mac OS X
    Sep 9, 2016 9:12 PM in response to momogabi

    Here's another way that uses a "Counter" column that you can then use to generate a list of people that attended at least once:

     

    Screen Shot 2016-09-09 at 11.55.01 PM.png

     

    The formula in P2, filled down, is:

     

      =IF(COUNTIF(I2:O2,"Y")>0,MAX(P$1:P1)+1,"")

     

    This increments a counter by one whenever a name with at least one Y is encountered.

     

    The formula in A1 of the 'Attended at Least Once' table, filled down, is:

     

       =IFERROR(INDEX(Table 1::C,MATCH(ROW(),Table 1::P,0)),"")

     

    This takes the row number where the formula appears and looks it up in column P of the first table.  The row number it finds is then fed to the INDEX function, which retrieves the value (name) that appears in column C.  The IFERROR suppresses the red warning triangle if you have added more rows than the first table has.

     

    The formula in the last cell of the 'Attended at Least Once' table, is:

     

         =COUNTIF(A,"<>"&"")

     

    This simply counts cells that are not displaying a blank.

     

    Note that the 'Name' column contains distinct names (i.e. you can't have more than one exactly the same there). Usually a first initial and last name will be enough to distinguish the names.

     

    In Numbers it's a good idea to have compact tables that do not include a lot of blank rows as in your example.  Recommend having a look at the templates at File > New in your menu for ideas about how Numbers tables should look.  You'll get better results if you pay attention to the table-centric design of Numbers and avoid the great sea of cells on a sheet as you often find in Excel.

     

     

    SG

  • by MD_Gene,

    MD_Gene MD_Gene Sep 10, 2016 10:19 AM in response to momogabi
    Level 1 (20 points)
    Desktops
    Sep 10, 2016 10:19 AM in response to momogabi

    Can one assume that each row is a unique individual?  If so, a "sumif" function can be used across each row.  Where the cells in the sumif column is >0 the person attended.