+ Reply to Thread
Results 1 to 7 of 7

Counting Unique Values in a table based upon criteria of other columns

  1. #1
    Registered User
    Join Date
    04-07-2011
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    19

    Counting Unique Values in a table based upon criteria of other columns

    Hey all,

    So I have a table that has roughly 250,000 rows that looks like this:

    The Customer # and State fields are text types, and the Sales and Year fields are number types.

    Customer # - Sales - Year - State
    000001 - $100.00 - 2011 - VT
    000001 - $200.00 - 2010 - VT
    000002 - $500.00 - 2011 - CA
    000003 - $100.00 - 2011 - VT
    000004 - $0.00 - 2010 - VT
    000004 - $50.00 - 2011 - VT
    000004 - $100 - 2011 VT


    What I'm looking to do is to write a formula that counts the number of unique customer numbers (customers) who have sales greater than $0, in 2011, and are in the state of VT.

    Using the table above, I should get back the number 3, as there are three different customer numbers who have some positive sale in 2011 in Vermont (Records 1, 4 and 6 and 7 qualify all criteria, but then since 6 and 7 contain the same customer number only 1 would count towards my total number).

    Any ideas? I've toyed around with countif(s) and am still a bit stumped.
    Last edited by SoleAris; 10-11-2011 at 06:10 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-23-2011
    Location
    Lahore PK
    MS-Off Ver
    Excel 2007, 2013
    Posts
    627

    Re: Counting Unique Values in a table based upon criteria of other columns

    see attatchment
    Attached Files Attached Files
    Azam
    If you want to say Thank you to a member, click the reputation icon (Star) in the left bottom of the post.
    For prompt answer, be descriptive, concise, short, direct, and to-the-point.

  3. #3
    Forum Contributor
    Join Date
    03-31-2009
    Location
    Childers QLD, Australia
    MS-Off Ver
    Excel 2003, 2007 & 2013
    Posts
    128

    Re: Counting Unique Values in a table based upon criteria of other columns

    Hi,

    I looked at your problem and used a method the works in the attached spreadsheet.

    See what you think.

    Cheers

    TonyB
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-07-2011
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Counting Unique Values in a table based upon criteria of other columns

    Thanks for the replies guys. I'm still having a bit of trouble even with your suggestions, so I figured I'd make a more vivid and detailed example for you to look at if you still will.

    Attached is a file that has 3 sheets:

    #1 as the "Report Sheet" which is where I need the number of unique customers shown (area colored orange).

    #2 is the "Master Sales Table" which holds those 250,000 records. I made the table look much more like my actual sales table, but still need the same criteria from it. This table is linked directly from Access, so in referencing a column I reference the entire column (i.e. $A:$A).

    #3 is the "Customer List" table which is simply a list of all of my customers, their name, and then their State that they are located in if that helps.


    I'm hoping to be able to write a formula that can give me the number of unique customers who have positive sales in 2011 who reside in VT. Once I get that, obviously altering the formula for the year 2010 or a different state will be easy.

    Thanks so much for the help guys!
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    03-31-2009
    Location
    Childers QLD, Australia
    MS-Off Ver
    Excel 2003, 2007 & 2013
    Posts
    128

    Re: Counting Unique Values in a table based upon criteria of other columns

    Hi,

    I have added another Sheet Called Data Split.

    The purpose is to maintain the Formula's there.

    As you modify you Master Sales Table, everything on the Data Split Sheet will update.

    As will your Report Sheet.

    Check all the formula's in the whole workbook.

    Formula's in Column's A - L can be fiiled down the page, as can Column's N thru T.

    However, the SUM values in Row O3 to T3 will ne to be expanded to capture all values.

    See what you think.

    Cheers

    TonyB
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-07-2011
    Location
    Portland, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Counting Unique Values in a table based upon criteria of other columns

    I see where you're going with your example, however doing that for about 300,000 rows is something excel/my computer does not like to process using the drag tool. 300,000 rows by 50 states x 5 different years is a lot for it to handle..

  7. #7
    Forum Contributor
    Join Date
    03-31-2009
    Location
    Childers QLD, Australia
    MS-Off Ver
    Excel 2003, 2007 & 2013
    Posts
    128

    Re: Counting Unique Values in a table based upon criteria of other columns

    Hi,

    Just a thought, how do you fill down?
    The quickest method is to select the cell you wish to fill down, then while holding the CTRL and Shift Keys use you Arrow Down Key. Then once selected use CTRL D to fill.

    Cheers

    TonyB

+ 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