Return the number of unique values in a date range that contain a key sentence

HatchetHarry

New Member
Joined
Aug 20, 2018
Messages
16
Office Version
  1. 365
Moderator edit: Google Sheets question - see post #6

Let's say I have a line with 3 data: email, date of purchase, location

The formula will check that the customer purchased last month, the location is 'Location 1' and will count only ONCE this customer even though he could have bought multiple times last month.

I have 2 formulas that are working individually but I'm struggling to combine:
The first one is checking the last month entries (COL B) and also checking if the cell contains 'Location 1' sentence (COL C) then returns the total.
=COUNTIFS('Orders'!B:B,">=" & EOMONTH(TODAY(),-2)+1,'Orders'!B:B,"<" & EOMONTH(TODAY(),-1)+1, 'Orders'!C:C,"Location 1")

The second one is checking for unique values using the email address.
=SUMPRODUCT(1/COUNTIF(A2:A6,A2:A6))
*To note that if the cell is empty it will return in error, so bonus point if someone can help me to get the full range (i.e: =SUMPRODUCT(1/COUNTIF(A:A,A:A))

Screenshot 2023-01-19 at 6.05.03 PM.png


From the screenshot above:
Date: MM/DD/YYYY
Unique customers from LAST month should be 2 at Location 1.

Any idea on how to combine them?
Thanks a lot.
 

Attachments

  • Screenshot 2023-01-19 at 6.03.03 PM.png
    Screenshot 2023-01-19 at 6.03.03 PM.png
    35.8 KB · Views: 16
Last edited by a moderator:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

It would also help if you gave us the sample data in a form that we could copy to test with (eg XL2BB)
 
Upvote 0
Try this one
Excel Formula:
=COUNTA(UNIQUE(DROP(FILTER(A2:C7,--(MONTH(B2:B7)=MONTH(EOMONTH(TODAY(),-1)))*--(C2:C7="Location 1")),,-2)))
 
Upvote 0
Try this one
Excel Formula:
=COUNTA(UNIQUE(DROP(FILTER(A2:C7,--(MONTH(B2:B7)=MONTH(EOMONTH(TODAY(),-1)))*--(C2:C7="Location 1")),,-2)))
I think you would find that
- if zero rows match the conditions it would still return 1
- provided the other conditions match, it would include a row where the month was the previous month but in any year, not just last month.

@HatchetHarry
Thanks for updating your version details. (y)

Here is another one for you to try.

23 01 19.xlsm
ABCDE
1
2a22/12/2022Location 12
3a12/12/2022Location 1
4b18/01/2023Location 2
5c19/12/2022Location 1
6c19/12/2022Location 1
7c12/01/2023Location 1
Count
Cell Formulas
RangeFormula
E2E2=IFNA(ROWS(UNIQUE(FILTER(A2:A7,(TEXT(B2:B7,"mmyy")=TEXT(EDATE(TODAY(),-1),"mmyy"))*(C2:C7="Location 1"),NA()))),0)
 
Upvote 0
Hi again.
My team decided to make it collaborative so I need to change to Google Sheet... (sorry about that).
Upon testing both formula on Google Sheet and taking @Peter_SSs data, it returns 0 and @shinigamilight returns 1

I'm not sure you are familiar with Google Sheet.
If you have any idea that's great otherwise thanks a lot for your help.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,224
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top