+ Reply to Thread
Results 1 to 11 of 11

Countif unique values with multiple criteria

  1. #1
    Forum Contributor
    Join Date
    07-04-2013
    Location
    United States
    MS-Off Ver
    Excel for Mac -V 16.33 -- Office 365
    Posts
    279

    Countif unique values with multiple criteria

    I am trying to count the number of customers with the same unique ID who shop at other area stores in our system. For example, how many customers shop at both "Madison" and Westerly". This value tells me the number of customers who "crossover" and shop at both stores.

    Attached is a sample of the file I am looking to add formulas to.

    Thanks in advance for your feedback.
    Attached Files Attached Files

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Countif unique values with multiple criteria

    is "Madison" > Westerly" and Westerly" > "Madison" not equal?
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,935

    Re: Countif unique values with multiple criteria

    Try

    G5
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  4. #4
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Countif unique values with multiple criteria

    Hi all- This formula uses these names: Store and Customer_ID. To define a Named Range, select the data, click Define Name on the Formula tab, and type in the name. Then paste this ARRAY FORMULA* in G5 and copy down:
    *Always press CTRL+SHIFT+ENTER to confirm entry after pasting or editing an ARRAY FORMULA in the Formula Bar.
    When copying the formula to other cells, make sure the copied cell is not part of the Paste Area.

    Please Login or Register  to view this content.
    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    3
    Number
    Customer ID
    Store
    Formula
    4
    1
    10037
    Madison
    Store
    Brentwood
    Madison
    Nexus
    Westerly
    5
    2
    10037
    Westerly
    Brentwood
    0
    0
    2
    3
    6
    3
    10054
    Madison
    Madison
    0
    0
    1
    3
    7
    4
    10054
    Westerly
    Nexus
    2
    1
    0
    1
    8
    5
    10060
    Madison
    Westerly
    3
    3
    1
    0
    9
    6
    10067
    Madison
    10
    7
    10147
    Brentwood
    Attached Files Attached Files
    Last edited by leelnich; 08-26-2017 at 04:15 AM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

  5. #5
    Forum Contributor
    Join Date
    07-04-2013
    Location
    United States
    MS-Off Ver
    Excel for Mac -V 16.33 -- Office 365
    Posts
    279

    Re: Countif unique values with multiple criteria

    Perfect. This is exactly what I was looking for. Thank you!

  6. #6
    Forum Contributor
    Join Date
    07-04-2013
    Location
    United States
    MS-Off Ver
    Excel for Mac -V 16.33 -- Office 365
    Posts
    279

    Re: Countif unique values with multiple criteria

    This too is a great solution. Adding the names makes this very intuitive. Thank you!

  7. #7
    Forum Contributor
    Join Date
    07-04-2013
    Location
    United States
    MS-Off Ver
    Excel for Mac -V 16.33 -- Office 365
    Posts
    279

    Re: Countif unique values with multiple criteria

    Yes. That is correct. The solutions posted were just what I was looking for. Thank you for view this.

  8. #8
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Countif unique values with multiple criteria

    Hi all- @Perk1961, the solutions offered in posts #3 and #4 return COMPLETELY different results. Which one (if either) is correct?
    Postscript-27 AUG 2017 - The above statement is incorrect. I failed to adjust Ankur's formula to fit the same data range as mine. Apologies to all.
    Last edited by leelnich; 08-27-2017 at 01:11 PM.

  9. #9
    Forum Contributor
    Join Date
    07-04-2013
    Location
    United States
    MS-Off Ver
    Excel for Mac -V 16.33 -- Office 365
    Posts
    279

    Re: Countif unique values with multiple criteria

    The one I used was by shukla. That said, after looking at Leelnich's formula the version by Shukla did not address duplicate records (Customer ID's with the same Store). The formula by leelnich produced the same results but excluded duplicates which made for a more robust solution. The only problem I found was that Leelnich included an attached file where that formula was properly applied to the first row (G5:J5) but then was not copied down to the cells below. Once I copied that formula to all the cells then the results were the same as Shukla's.

    Again, the formula by Shukla and Leelnich both seem to work the same if there are no duplicates, but the formula by Leelnich's also excludes duplicates.

    At the end of the day, my data did not have duplicates so either one worked for me. Also, the formula by Shukla was MUCH faster than the one by Leelnich. Not sure why, but just guessing there were more calculations that had to take place to assure duplicates were not included.
    Last edited by Perk1961; 08-27-2017 at 11:09 AM.

  10. #10
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Countif unique values with multiple criteria

    Apologies to all. My original assertion in post #8 was incorrect; Ankur's formula does in fact agree with mine (if duplicates are removed). I failed to correctly adjust the ranges used in his formula.
    Nicely done, Ankur!
    Last edited by leelnich; 08-27-2017 at 01:43 PM.

  11. #11
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Countif unique values with multiple criteria

    BTW @shukla.ankur281190, I think the "bins" clause of your formula could be simplified:
    Please Login or Register  to view this content.
    Any reason you didn't go with that? - Lee

+ 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. sum unique values with multiple criteria
    By tahas in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-17-2017, 02:03 AM
  2. [SOLVED] Countif with multiple criteria to take unique values only
    By kasun in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-17-2014, 03:36 AM
  3. [SOLVED] Sum unique values with multiple criteria
    By Billaus in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 10-11-2014, 10:48 PM
  4. count unique values in multiple worksheets with multiple criteria
    By craig04 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-06-2012, 03:26 PM
  5. Replies: 7
    Last Post: 07-19-2012, 10:22 AM
  6. Macro to remove duplicates values and keep unique values bases on multiple criteria
    By Ricker090 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-16-2011, 04:37 PM
  7. Replies: 5
    Last Post: 06-13-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