+ Reply to Thread
Results 1 to 7 of 7

Distinct COUNTIF

  1. #1
    Registered User
    Join Date
    12-11-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 365
    Posts
    70

    Distinct COUNTIF

    Hi

    Apologies, can't upload from work, so I will do my best to explain what I am trying to do (and hope for the best!)

    I have 2 x Columns of data, Column A has account number and Column B has item purchased (there are only 4-5 different items).

    I need to summarise this info. So, summarising the items purchased is easy, but I also need to summarise purchases by distinct account. So, for example, look at a product in Column B, we've sold a totol of e.g 700 of them, but I need to know how many unique account numbers have purchased that item, so I might have 700 purchases, but 350 account numbers have bought 2 each. So I'd need my "distinct count" to show 350 there.

    I have my list of the 4-5 items available for purchase in a table in a different sheet tab.

    Does that make sense?

    Thanks

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Distinct COUNTIF

    Use countifs or pivot table


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Distinct COUNTIF

    Hi theNewUnion

    Try pivot table here.. move account number in row field and item purchased in data field as sum / count as per your need AND you'll have unique account numbers in row field anywayas

    regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  4. #4
    Registered User
    Join Date
    12-11-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 365
    Posts
    70

    Re: Distinct COUNTIF

    Yeah, just done a pivot table for it now and it works fine. Had been trying to work out a formula to do it, just for kicks, but I couldn't come up with anything. Would still be interested if anyone can do it with a formula!

    Cheers guys

    TNU

  5. #5
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Distinct COUNTIF

    I stuck a list of account numbers in cells A1:A8 and then used this formula:

    =SUMPRODUCT(--(ROW(A1:A8)=MATCH(A1:A8,A1:A8,0)))

    Edited to add: If your column has a header row then the formula becomes:

    =SUMPRODUCT(--(ROW(A2:A8)=MATCH(A2:A8,A1:A8,0)))

    Two of the range references exclude the header row, but the final reference must include it.
    Last edited by Andrew-R; 12-19-2012 at 06:04 AM.

  6. #6
    Registered User
    Join Date
    12-11-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 365
    Posts
    70

    Re: Distinct COUNTIF

    Superb, I will try it now.

    (what's the deal with the -- seen it in a few formula on here but never really understood its purpose)

    Thanks

    TNU

    Edit: Looks like a distinct count on a specific column, is there a wayof adapting so it only applies the count if a certain criteria in Clumn B is met, kind of like a COUNTIF wrapped around the Distinct formual)

    Cheers
    Last edited by TheNewUnion; 12-19-2012 at 06:11 AM.

  7. #7
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Distinct COUNTIF

    The --(Statement) forces a TRUE/FALSE statement to convert to 1/0, which is handy if you want to sum them inside a SUMPRODUCT.

    So, my formula gets the row for each cell in the range A1:A8 (i.e. it returns {1,2,3,4,5,6,7,8}) and then looks up each cell value in the same range. If the value hasn't previously appeared then the MATCH will return the same number as the row and the statement will return TRUE, if the value has previously appeared then the MATCH will return a lower value than ROW and the statement will return FALSE.

    The -- then converts TRUE to 1 and FALSE to 0 and adds them up, which gives a count of the number of unique entries.

  8. #8
    Registered User
    Join Date
    12-11-2012
    Location
    Manchester, UK
    MS-Off Ver
    Excel 365
    Posts
    70

    Re: Distinct COUNTIF

    Excellent explanation Andrew-R, makes sense really but it never clicked before. Thanks for the response.

+ 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