Formula to unique count with criteria based on a given year

goethe168

New Member
Joined
Oct 3, 2023
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
I'm using Excel 2019, and I have a table with 3 columns ABC containing

Order date | Order ID | Customer name

I need a formula to count the unique orders per customer based on a given “year”.

So in E2 will be a customer’s name and in E3 I’ll enter a year say 2023, and in F3 should be a formula to count unique orders of that customer within the year 2023.

The order date in column A is in the date format of YYYY-MM-DD

Any help would be appreciated!
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Someone might have a better solution, but mine required an addtional column. Excel 2019 posted a challenge as it did not have the UNIQUE() function.

Book1
ABCDEFG
1Order DateOrder IDCustomer nameFiltered ID
21/10/111A4Year 2018
32/13/111A3Customer NameC
42/11/123C1Unique Order Count3
53/17/121D4
68/17/122A4
77/23/162A
81/1/185B
91/5/184C
105/3/183C
118/12/181C
125/12/184C
135/12/184C
Sheet1
Cell Formulas
RangeFormula
D2:D6D2=FILTER(B2:B13,(YEAR(A2:A13)=G2)*(C2:C13=G3))
G4G4=SUMPRODUCT(IF(D2:D13<>"",1/COUNTIF(D2:D13,D2:D13)))
Dynamic array formulas.
 
Upvote 0
Filter does not, and never has, existed in 2019. Unfortunately it does not help when MS cannot even get right themselves on this page FILTER function - Microsoft Support
This MS site is more reliable Excel functions (alphabetical) - Microsoft Support
hmm... It doesn't help for sure when the official source isn't correct. It makes sense that Excel2019 did not have access to the dynamic array so functions like FILTER, SORT, and UNIQUE...so it should be obvious that FILTER() isn't in the list.

Thanks for the info. Back to the drawing board.
 
Upvote 0
Okay, how about this using IF...

Book1.xlsx
ABCDEFG
1Order DateOrder IDCustomer nameFiltered OrderID
21/10/20111A Year 2018
32/13/20111ACustomer NameC
42/11/20123CUnique Order Count3
53/17/20121D
68/17/20122A
77/23/20162A
81/1/20185B
91/5/20184C4
105/3/20183C3
118/12/20181C1
125/12/20184C4
135/12/20184C4
Sheet1
Cell Formulas
RangeFormula
D2:D13D2=IF((YEAR(A2:A13)=G2)*(C2:C13=G3)=1,B2:B13,"")
G4G4=SUMPRODUCT(IF(D2:D13<>"",1/COUNTIF(D2:D13,D2:D13)))
Dynamic array formulas.
 
Upvote 0
Thanks for all your replies!

I'VE managed to figure out a few array formulae as below, which worked. However, the problem is that they don't work on a huge data set :(


=SUM(IF(($C$2:$C$5=E2)*(YEAR($A$2:$A$5)=E3),(1/COUNTIFS($C$2:$C$5,$C$2:$C$5,$B$2:$B$5,$B$2:$B$5)),0))

=SUM(IF(FREQUENCY(IF((C2:C5=E2)*(YEAR($A$2:$A$5)=E3),B2:B5),B2:B5),1))
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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