+ Reply to Thread
Results 1 to 3 of 3

Count Unique Values with multiple criteria

  1. #1
    Registered User
    Join Date
    02-29-2012
    Location
    Linthicum, MD
    MS-Off Ver
    Excel 2013
    Posts
    52

    Count Unique Values with multiple criteria

    Good morning,

    For this exercise I need to get a total of all AZ, Off, Orders with a value of "1" but only counting each repeating ID number once (for orders of 1). This is a shortened version with the full spreadsheet containing On and Off Premise, 8 different states and multiple order counts. I've attached an example with a grid to the right which will be my final outcome but need the first formula that I can then alter as needed. The Unique part is what is stopping me. I can count the Orders with 1, but it is counting all of them and not the unique ones.

    Orders ID Premise State
    1 9170751 OFF AZ
    1 9170751 OFF AZ
    1 9170752 OFF AZ
    1 9170757 OFF AZ
    1 9170757 OFF AZ
    0 9170752 OFF AZCount Unique Values.xlsx
    10 9170751 OFF AZ
    12 9170752 OFF AZ
    11 9170757 OFF AZ
    0 9170757 OFF AZ
    2 9170751 OFF AZ
    8 9170757 OFF AZ
    2 9184526 OFF AZ

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Count Unique Values with multiple criteria

    Ok, see attached.

    I used a couple of helper columns to get the 'count distinct ID' you were looking for.

    First helper: =A2&C2&D2&"-"&B2 Combines the other column values into a kind of lookup key.

    Second helper: =1/COUNTIF($E$2:$E$1793,E2) This gives you something to sum up in the final table for 'count distinct' (you could use this column in a pivot table (sum) to get a count distinct)

    Pivot Option
    *State field in ROW
    *Orders field in COLUMNS
    *Sum of Helper2 in VALUES
    *Premise field in FILTER

    If you skip the pivot table, you could use this worksheet function in the "OFF" table
    =SUMPRODUCT(($A$2:$A$1793=I$1)*($C$2:$C$1793=$H$1)*($D$2:$D$1793=$H2)*($F$2:$F$1793))

    SEE ATTACHMENT to see the proper context of each reference.
    Attached Files Attached Files
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Registered User
    Join Date
    01-13-2015
    Location
    Leicester, England
    MS-Off Ver
    2013
    Posts
    42

    Re: Count Unique Values with multiple criteria

    Added on sheet1 the formula though it might slow down the spreadsheet. In sheet2as an alternative,, I added a pivot table (and selected the "Add this data to the Data Model" check box) so that I can count distinct values.
    Alex
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Count unique values with multiple criteria from same column
    By AlexandraT in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-23-2015, 12:46 PM
  2. Count Unique Values for Multiple Criteria
    By timjs in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-03-2015, 10:09 AM
  3. Count unique values based on multiple criteria
    By Jonathan11235 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 05-19-2015, 10:02 PM
  4. Count unique values across 2 columns with multiple criteria
    By Skywalker01 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-29-2012, 08:04 AM
  5. Replies: 8
    Last Post: 07-13-2012, 06:00 AM
  6. Count Unique Values, but with multiple criteria
    By the northern monkey in forum Excel General
    Replies: 3
    Last Post: 02-02-2012, 07:45 AM
  7. Count Unique Values with Multiple Criteria
    By JohnV in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-17-2006, 01:10 PM

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