+ Reply to Thread
Results 1 to 4 of 4

Formula to count unique instances

  1. #1
    Forum Contributor
    Join Date
    10-11-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    230

    Formula to count unique instances

    I have a workbook with two worksheets in it. Each sheet has col A, B, C, D with the same headers. The first sheet has rows and rows of data with the data info in these columns (could be unique or repetitive) yet other unique data in the rest of the columns on the file. This first sheet shows the details of each transaction.

    The second sheet is used to sum up those transactions. I need a formula for sheet 2 column D that will count the unique items in sheet 1 column D if the first three columns on each sheet match. Example below:

    Sheet 1:
    Col A Col B Col C Col D Col E
    Set 1 Batch 1 Item 1 Unit 1 $100
    Set 1 Batch 1 Item 1 Unit 2 $100
    Set 1 Batch 2 Item 1 Unit 1 $100
    Set 1 Batch 1 Item 2 Unit 1 $100
    Set 1 Batch 1 Item 2 Unit 1 $125
    Set 1 Batch 1 Item 2 Unit 2 $125
    Set 1 Batch 1 Item 2 Unit 3 $125


    Sheet 2:
    Col A Col B Col C Col D
    Set 1 Batch 1 Item 1 need formula here that will tell me how many unique units are in sheet 1 Column D that also have Set 1, Batch 1, and Item 1 in the first 3 columns respectively.

    Thanks

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formula to count unique instances

    Try this...

    Data Range
    A
    B
    C
    D
    E
    F
    G
    H
    I
    1
    ------
    ------
    2
    Set 1
    Batch 1
    Item 1
    Unit 1
    Set 1
    Batch 1
    Item 1
    2
    3
    Set 1
    Batch 1
    Item 1
    Unit 2
    4
    Set 1
    Batch 2
    Item 1
    Unit 1
    5
    Set 1
    Batch 1
    Item 2
    Unit 1
    6
    Set 1
    Batch 1
    Item 2
    Unit 1
    7
    Set 1
    Batch 1
    Item 2
    Unit 2
    8
    Set 1
    Batch 1
    Item 2
    Unit 3


    This array formula** entered in I2:

    =SUM(IF(FREQUENCY(IF((A2:A8=F2)*(B2:B8=G2)*(C2:C8=H2),MATCH(D2:D8,D2:D8,0)),ROW(D2:D8)-ROW(D2)+1),1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Forum Contributor
    Join Date
    10-11-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    230

    Re: Formula to count unique instances

    Tony,

    Can you explain "-ROW(D2)+1),1))"
    Since my data is on 2 sheets and I'm looking at the entire columns of data on Sheet 1, I'm not sure why this section of the formula only references one cell on Sheet 1 Column D.
    Thanks.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Formula to count unique instances

    The MATCH function will return an array of numbers from 1 to N.

    The ROW function also has to return an array from 1 to N. To get that array we use this expression:

    ROW(D2:D8)-ROW(D2)+1

    Which will generate the array:

    ROW(D2)-ROW(D2)+1 = 1
    ROW(D3)-ROW(D2)+1 = 2
    ROW(D4)-ROW(D2)+1 = 3
    ROW(D5)-ROW(D2)+1 = 4
    ROW(D6)-ROW(D2)+1 = 5
    ROW(D7)-ROW(D2)+1 = 6
    ROW(D8)-ROW(D2)+1 = 7

    {1;2;3;4;5;6;7}

+ 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. [SOLVED] Count Unique Instances of Date while filtering based upon date and ID #
    By pmambrosetti in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-15-2014, 02:22 PM
  2. Unique count of number of instances
    By arnab0711 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-08-2013, 03:09 AM
  3. Formula to count instances
    By john dalton in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-09-2013, 04:33 AM
  4. Replies: 8
    Last Post: 01-30-2013, 02:58 PM
  5. Count Unique instances across several Columns
    By Leigh.Odonnell in forum Excel General
    Replies: 5
    Last Post: 05-14-2012, 06:05 PM
  6. Search a list and count unique instances and match
    By eeanil in forum Excel General
    Replies: 2
    Last Post: 04-24-2012, 12:36 AM
  7. Count unique instances
    By meweaver27 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-28-2007, 09:57 AM

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