+ Reply to Thread
Results 1 to 5 of 5

Count unique (text) values based on two criteria

  1. #1
    Registered User
    Join Date
    12-10-2010
    Location
    Singapore
    MS-Off Ver
    MS Excel for Mac 2011
    Posts
    51

    Count unique (text) values based on two criteria

    BACKGROUND
    I have two sheets: ANALYSIS and DATA. The formula is in sheet ANALYSIS, the data in sheet DATA.

    TASK
    I need to count the unique (text) values in column Data!$f$5:$f$1137, based on two criteria:
    1. the presence of the (text) value c2 in column Data!$N$5:$N$1137 AND
    2. the presence of the (text) value $B$2 in column Data!$L$5:$L$1137

    FAULTY FORMULA
    The formula I tried to use reads as follows:
    =SUM(IF((c2=Data!$N$5:$N$1137)*
    (Data!$L$5:$L$1137=$B$2)),
    1/(COUNTIFS(Data!$N$5:$N$1137,c2,
    Data!$f$5:$f$1137,Data!$f$5:$f$1137,
    Data!$L$5:$L$1137,&Data!$N$5:$N$1137)), 0))
    Ctrl Shift Enter

    RESULT
    Whatever I try, I continue to get a “The formula you typed contains an error”

    REQUEST
    Can someone tell me what the error in my formula is?
    PS: I need to resolve the above, before I can start on a separate analysis to count unique (text) values, not on two but on three criteria.

    Thanking the forum in advance,
    Gijs

  2. #2
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Count unique (text) values based on two criteria

    If you attach a workbook (not pictures) with some data and the expected output it will be much easier to help you.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  3. #3
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Count unique (text) values based on two criteria

    Something like this, CSE formula. But is hard to guess, so a sample would be better:

    =SUM(IF(FREQUENCY(IF(Data!$N$5:$N$1137=$C2,IF(Data!$L$5:$L$1137=$B$2,IF(Data!$f$5:$f$1137<>"",MATCH(Data!$f$5:$f$1137,$Data!$f$5:$f$1137,0)))),ROW(Data!$f$5:$f$1137)-ROW(Data!$f5)+1),1))

  4. #4
    Registered User
    Join Date
    12-10-2010
    Location
    Singapore
    MS-Off Ver
    MS Excel for Mac 2011
    Posts
    51

    Re: Count unique (text) values based on two criteria

    Thank you Paul, for the instant response.

    There was a small error in your formula, but that was easy to fix:
    =SUM(IF(FREQUENCY(IF(Data!$N$5:$N$1137=$C2,IF(Data!$L$5:$L$1137=$B$2,IF(Data!$f$5:$f$1137<>"",MATCH(Data!$f$5:$f$1137,$Data!$f$5:$f$1137,0)))),ROW(Data!$f$5:$f$1137)-ROW(Data!$f5)+1),1))

    The formula works like a charm, except for one value that returns a #VALUE!

    I have however two follow-up question:
    1. Is the SUM IF FREQUENCY a better formula then the SUM IF COUNTIFS?
    2. Since I have several worksheets to work this formula on, with an excess of date (>6,000 rows), is it recommended to use an entire column (e.g. Data!$N:$N) instead of the specific cells in the column Data!$N$5:$N$1137 Or will this slow the formula down?

    Thanks again Paul!

  5. #5
    Registered User
    Join Date
    12-10-2010
    Location
    Singapore
    MS-Off Ver
    MS Excel for Mac 2011
    Posts
    51

    Re: Count unique (text) values based on two criteria

    Quote Originally Posted by Jacc View Post
    If you attach a workbook (not pictures) with some data and the expected output it will be much easier to help you.
    Please find attached the workbook. Thanks for the help!
    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. [SOLVED] Count Unique Values based on 2 criteria
    By spyac in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-15-2018, 01:04 AM
  2. count unique values based on between dates with a criteria
    By FUN2BALA in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 11-22-2017, 04:55 AM
  3. Replies: 11
    Last Post: 11-16-2017, 07:11 AM
  4. [SOLVED] Count unique text values with criteria
    By andrugrasu in forum Excel General
    Replies: 11
    Last Post: 09-10-2017, 08:35 AM
  5. [SOLVED] Count unique values based on criteria without using array
    By jonpaulson in forum Excel General
    Replies: 14
    Last Post: 10-10-2014, 06:30 PM
  6. Count unique text values using criteria
    By roadbiker in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-27-2013, 12:13 PM
  7. Count unique values based on several criteria
    By evilgrin in forum Excel General
    Replies: 2
    Last Post: 10-10-2010, 03:50 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