+ Reply to Thread
Results 1 to 6 of 6

Count Unique instances across several Columns

Hybrid View

  1. #1
    Registered User
    Join Date
    05-13-2012
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    2

    Count Unique instances across several Columns

    I have a spreadsheet with several columns (20 odd) and several thousand rows (10187!)
    See "data" Tab for a watered down version
    I need to count the total number of shifts worked (for a given period - say monthly)

    Ie: in the data sheet Equip # 111 - how many shifts did it work in April , then May

    There are several line descriptions for each date & shift worked
    Some work day & night shift - some only work days

    I would like a formula - Not sorting/filtering -( I can do that) but I am doing this all the time & would like a better more robust way to calculate.

    Thanks if you can help.
    Leigh

  2. #2
    Forum Contributor Russell Dawson's Avatar
    Join Date
    03-01-2012
    Location
    Yorkshire, England
    MS-Off Ver
    2007
    Posts
    608

    Re: Count Unique instances across several Columns

    Hi

    I've come up with the attached which includes this array formula -

    =SUM((C2:C50=$J$2)*(H2:H50=$K$2)*(D2:D50=$L$2)*(F2:F50=M2))

    So enter with Ctrl-Shift-Ent

    It requires a helper column for the month number and requires you to input month number.
    Updated with improved s/s to show all permutations
    Last edited by Russell Dawson; 05-14-2012 at 03:11 AM. Reason: Updated attachment
    If I helped, please don't forget to add to my reputation. (click on the star below the post)

    If the problem is solved, please: Select Thread Tools (on top of your 1st post) -> Mark this thread as Solved.

    Failure is not falling down but refusing to get up.

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Count Unique instances across several Columns

    Hi Welcome to the forum.

    A SUMPRODUCT, version..

    Start date =J1

    End date =J2

    For all "111"

    =SUMPRODUCT(($C$2:$C$53=111)*($E$2:$E$53>=$J$1)*($E$2:$E$53<=$J$2))
    For Day
    =SUMPRODUCT((($C$2:$C$53=111)*($F$2:$F$53="Day")*($E$2:$E$53>=$J$1)*($E$2:$E$53<=$J$2)))
    For night
    =SUMPRODUCT((($C$2:$C$53=111)*($F$2:$F$53="Night")*($E$2:$E$53>=$J$1)*($E$2:$E$53<=$J$2)))
    Is this, works for you?
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Registered User
    Join Date
    05-13-2012
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Count Unique instances across several Columns

    Thanks , but I need the number of "shifts" Calculated.
    If equip # 111 has 3 description lines for 1/4/2012 on day shift = 1 shift
    If equip # 111 has 3 description lines for 1/4/2012 on day shift and 2 description lines for night shift = 2 shifts
    If equip # 111 has 3 description lines for 1/4/2012 on day shift & 3 description lines for 2/4/12 day shift = 2 shifts
    Any ideas?

    Thanks Leigh

  5. #5
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: Count Unique instances across several Columns

    see if this helps. with this, you could find HOURS for just 111, or 111 + Day shift, or just DAY shift, or 111 + April... try it out.

    you have some white spaces in your data, which scupper calculations.
    Last edited by icestationzbra; 05-14-2012 at 02:46 AM.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  6. #6
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    365
    Posts
    2,243

    Re: Count Unique instances across several Columns

    Try this, with CTRL+SHIFT+ENTER, rather than just ENTER

    =SUM(IF(FREQUENCY(IF(C$2:C$53=Equip,IF((E$2:E$53>=StartDate)*(E$2:E$53<=EndDate),IF(F$2:F$53<>"",MATCH(E$2:E$53&"|"&F$2:F$53,E$2:E$53&"|"&F$2:F$53,0)))),ROW(F$2:F$53)-ROW(F$2)+1),1))
    Of Course should have more intellectual ways.

    Change the Equipment, Start & End Dates.
    Last edited by Haseeb Avarakkan; 05-14-2012 at 06:09 PM.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1