Counting distinct combo of multiple values within date range

excellenthelp

New Member
Joined
Mar 25, 2016
Messages
2
I've been stuck on this for a while now and would great appreciate any input you may have on this. I have a table with two values, Region and 'Start Date'. What I would like to do is get a count of all distinct combinations within a specified date range. I have 2 tables below, one to show an example of my data and another to show what I'm expecting from my output table.

[TABLE="width: 500"]
<tbody>[TR]
[TD]Central[/TD]
[TD]1/31/16[/TD]
[/TR]
[TR]
[TD]Central[/TD]
[TD]1/31/16[/TD]
[/TR]
[TR]
[TD]Central[/TD]
[TD]3/15/16[/TD]
[/TR]
[TR]
[TD]Central[/TD]
[TD]2/1/16[/TD]
[/TR]
[TR]
[TD]Central[/TD]
[TD]3/15/16[/TD]
[/TR]
</tbody>[/TABLE]


[TABLE="width: 500"]
<tbody>[TR]
[TD]Region[/TD]
[TD]S_Date[/TD]
[TD]E_date[/TD]
[TD]Count (What I'm solving for)[/TD]
[/TR]
[TR]
[TD]Central[/TD]
[TD]1/30/16[/TD]
[TD]3/1/16[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]Central[/TD]
[TD]3/2/16[/TD]
[TD]4/2/16[/TD]
[TD]1[/TD]
[/TR]
</tbody>[/TABLE]

I have already have a formula for counting all occurrences where column A has 'Central' and the date in column B falls within a date range, but am having difficulty adapting this to only include exact matches once.

Code:
=COUNTIFS('Active + Archive'!S:S,'Data Summaries'!A12,'Active + Archive'!V:V,">="&B52,'Active + Archive'!V:V,"<="&D52)

S:S = my column for region denoting the criteria range to check
A12 = The value being checked in the range, in this case it's Central
V:V = The start date, date that I want to ensure is within the range
B52 = First date in the range I want to check
D52 = Last date in the range I want to check

I'm not sure if I need frequency, sumproduct, arrays, or what. From reading other posts I cobbled the below code together, but that's giving me decimals which can't be correct.

Code:
=SUMPRODUCT(IF(('Active + Archive'!V:V<=D52)*('Active + Archive'!V:V>=B52), 1/COUNTIFS('Active + Archive'!V:V, "<="&D52, 'Active + Archive'!V:V, ">="&D52, 'Active + Archive'!S:S, A52), 0))

Any insight you might be able to provide would be extremely appreciated, I'm suspecting that whatever I'm missing should be a quick fix (or at least that's what I'm hoping)!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
See if this works for you:

ABCD
Central
Central
Central
Central
Central
RegionS_DateE_dateCount
Central
Central

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"]1/31/2016[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]1/31/2016[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]3/15/2016[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]2/1/2016[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]3/15/2016[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]6[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]9[/TD]

[TD="align: center"]10[/TD]

[TD="align: right"]1/30/2016[/TD]
[TD="align: right"]3/1/2016[/TD]
[TD="align: right"]2[/TD]

[TD="align: center"]11[/TD]

[TD="align: right"]3/2/2016[/TD]
[TD="align: right"]4/2/2016[/TD]
[TD="align: right"]1[/TD]

[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet4

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: #DAE7F5"]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: #DAE7F5"]D10[/TH]
[TD="align: left"]{=SUM(IF(FREQUENCY(IF(($B$1:$B$5>=$B10)*($B$1:$B$5<=$C10)*($A$1:$A$5=$A10),$B$1:$B$5),$B$1:$B$5),1))}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
See if this works for you:

ABCD
Central
Central
Central
Central
Central
RegionS_DateE_dateCount
Central
Central

<tbody>
[TD="align: center"]1[/TD]

[TD="align: right"]1/31/2016[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]1/31/2016[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]3/15/2016[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]2/1/2016[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]3/15/2016[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]6[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]8[/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]9[/TD]

[TD="align: center"]10[/TD]

[TD="align: right"]1/30/2016[/TD]
[TD="align: right"]3/1/2016[/TD]
[TD="align: right"]2[/TD]

[TD="align: center"]11[/TD]

[TD="align: right"]3/2/2016[/TD]
[TD="align: right"]4/2/2016[/TD]
[TD="align: right"]1[/TD]

[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet4

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: #DAE7F5"]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: #DAE7F5"]D10[/TH]
[TD="align: left"]{=SUM(IF(FREQUENCY(IF(($B$1:$B$5>=$B10)*($B$1:$B$5<=$C10)*($A$1:$A$5=$A10),$B$1:$B$5),$B$1:$B$5),1))}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]


Just ran through some testing and that did the trick, thanks so much for your help!
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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