Counting unique values in range based on multiple criteria

SteveNL86

Board Regular
Joined
Nov 11, 2014
Messages
109
Office Version
  1. 2016
Platform
  1. Windows
Dear reader,

I am trying to count the unique values in a column, based on 1 week, 2 weeks and 3 weeks.

So I've done column C with an index/match formula, giving me unique weeknumbers ranging from 1 to 52.
I'm struggling with working out a working formula for column D, E & F.

In column D I'm just trying to get the total amoun to unique values for each week.
In column E I'm trying to get the same result but then for that week and the next week. So the results in E2 would be the total unique values for week 1 and 2.
In column F the same results but then for week 1, 2 & 3. F3 would give the results for week 2, 3 & 4.

Example:
ValueWeekUnique Week NumbersTotal Unique Values Per WeekTotal Unique Values Per 2 WeeksTotal Unique Value Per 3 Weeks
1011334
1512344
201323
15241
202
102
303
103
204

Any help is much appreciated!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Maybe:
Copy formulas in D2, E2 and F2 down the rows.
Book1
ABCDEF
1ValueWeekUnique Week NumbersTotal Unique Values Per WeekTotal Unique Values Per 2 WeeksTotal Unique Value Per 3 Weeks
21011334
31512344
4201323
515241
6202
7102
8303
9103
10204
Sheet1
Cell Formulas
RangeFormula
F2:F3F2=SUM(IF(FREQUENCY(IF($B$2:$B$10>=C2,IF($B$2:$B$10<=C4,MATCH($A$2:$A$10,$A$2:$A$10,0))),ROW($A$2:$A$10)-ROW($A$2)+1),1))
E2:E4E2=SUM(IF(FREQUENCY(IF($B$2:$B$10>=C2,IF($B$2:$B$10<=C3,MATCH($A$2:$A$10,$A$2:$A$10,0))),ROW($A$2:$A$10)-ROW($A$2)+1),1))
D2:D5D2=SUM(IF(FREQUENCY(IF($B$2:$B$10=C2,MATCH($A$2:$A$10,$A$2:$A$10,0)),ROW($A$2:$A$10)-ROW($A$2)+1),1))
 
Upvote 0
Solution
Thanks for the help AhoyNC but the formula don't seem to work for me. I only get a '1' a result in D2, E2, F2, and when dragging it down it only gives me #value errors unfortunately.

I even tried replicating exactly what you posted but it doesn't seem to give me the same results.
 
Upvote 0
You will need to confirm those formulae with Ctrl Shift Enter & then drag down.
 
Upvote 0
Ah yes, ofcourse. My bad! It seems to work, thanks for your help!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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