Countif/Sumif - only 1st instance

CROY1985

Well-known Member
Joined
Sep 21, 2009
Messages
501
Office Version
  1. 365
Platform
  1. Windows
Hi all

I have some data in the following layout:
DateRegionSnow
01/02/17Scotland1
02/02/17Scotland1
03/02/17Scotland0
08/02/17Scotland1
02/02/17Wales0
08/02/17Wales1

<tbody>
</tbody>

I need a formula which will will give me the total number of unique regions which have atleast 1 snow day between 2 seperately defined dates.

So say i define the dates as: 01/02/17 - 07/02/17 - the result should be 1, 08/02/17 - 14/02/17 the result would be 2.
That is to say in the first date range, Scotland had atleast 1 snow day, but wales had 0.
In the second date range both wales and scotland had 1 snowday, so the result would be 2.

Its the unique region bit that i'm stuck at.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
You need an array formula


A
B
C
D
E
F
G
1
Date​
Region​
Snow​
StartDate​
EndDate​
Result​
2
01/02/2017​
Scotland​
1​
01/02/2017​
07/02/2017​
1​
3
02/02/2017​
Scotland​
1​
08/02/2017​
14/02/2017​
2​
4
03/02/2017​
Scotland​
0​
5
08/02/2017​
Scotland​
1​
6
02/02/2017​
Wales​
0​
7
08/02/2017​
Wales​
1​
8

<tbody>
</tbody>


Array formula in G2 copied down
=SUM(IF(FREQUENCY(IF(A$2:A$7>=E2,IF(A$2:A$7<=F2,IF(C$2:C$7=1,IF(B$2:B$7<>"",MATCH(B$2:B$7,B$2:B$7,0))))),ROW(B$2:B$7)-ROW(B$2)+1),1))
Ctrl+Shift+Enter

M.
 
Upvote 0
You need an array formula


A
B
C
D
E
F
G
1
Date​
Region​
Snow​
StartDate​
EndDate​
Result​
2
01/02/2017​
Scotland​
1​
01/02/2017​
07/02/2017​
1​
3
02/02/2017​
Scotland​
1​
08/02/2017​
14/02/2017​
2​
4
03/02/2017​
Scotland​
0​
5
08/02/2017​
Scotland​
1​
6
02/02/2017​
Wales​
0​
7
08/02/2017​
Wales​
1​
8

<tbody>
</tbody>


Array formula in G2 copied down
=SUM(IF(FREQUENCY(IF(A$2:A$7>=E2,IF(A$2:A$7<=F2,IF(C$2:C$7=1,IF(B$2:B$7<>"",MATCH(B$2:B$7,B$2:B$7,0))))),ROW(B$2:B$7)-ROW(B$2)+1),1))
Ctrl+Shift+Enter

M.

Perfect, thank you so much.
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,104
Members
448,548
Latest member
harryls

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