How to count number of consecutive wet days in the a rainfall table?

yabi100

Board Regular
Joined
Aug 10, 2013
Messages
84
Office Version
  1. 2016
Platform
  1. Windows
I have a rainfall table and the google sheet link is provided below. For each year, I want to count number of days, fulfilling following both two conditions:

1) Number of days where rainfall is more than or equal to 1 mm.

2) Count only those days which are not single.
In other words, I want to count those days where at least two consecutive days are more than 1 mm.
This is called consecutive wet days in hydrology and I have to find a way in Excel to calculate them.
For example, in following part of the table as attached images:
Row 38 and 40 should not be counted because they are single, but rows 42 to 46 (5 days) should be counted, as they are consecutive and more than 1.
I have pasted the table into following link
I have to do it for each year separately. Separating years will be easy by putting a countif on year. But don't know how to perform consecutive days count.

Is there any way in Excel to perform this calculation?
 

Attachments

  • image1MrExcel.JPG
    image1MrExcel.JPG
    14.9 KB · Views: 14
  • image2MrExcel- WholeTable.JPG
    image2MrExcel- WholeTable.JPG
    46.1 KB · Views: 14
Here is some more analysis formulas. Enter in dates into J2:K4 to limit each row by date range. Enter in wet days for the count to calculate how many wet days there => the provided wet days. The maximum is also using the date ranges provided.

As far as your 100% and 90% only showing values: you must have a large number of days with zero rainfall. You may want to get a better resolution, down to .99, .98, etc.


Yabi100.xlsm
ABCDEFGHIJKLMN
1DateRainfall (mm)YearWet DaysCountPercentileWet DaysFirst DateLast DateWet DaysCountMaximum
21/1/202072020FALSE012601/1/202012/31/2020628665
31/2/202002020FALSE00.91021/1/202112/31/202110315260
41/3/2020312020TRUE130.8571/1/202212/31/202220175103
51/4/202082020TRUE120.742
61/5/2020382020TRUE110.632
71/6/2020312020TRUE100.524
81/7/2020272020TRUE90.417
91/8/202012020TRUE80.311
101/9/2020362020TRUE70.26
111/10/2020252020TRUE60.12
121/11/202042020TRUE500
131/12/2020112020TRUE4
141/13/2020272020TRUE3
151/14/202092020TRUE2
161/15/2020192020TRUE1
171/16/202032020FALSE0
181/17/202002020FALSE0
191/18/202032020TRUE10
201/19/2020382020TRUE9
Sheet1
Cell Formulas
RangeFormula
C2:C20C2=YEAR(A2)
D2:D20D2=AND(B2>=1,SUMIFS(B:B,A:A,A2+1,B:B,">="&1))
E2:E20E2=IF(D2=TRUE,COUNTA(OFFSET($D2,0,0,MATCH(FALSE,$D2:$D$1000000,0)-1,1)),0)
M2:M4M2=COUNTIFS($E:$E,">="&L2,$A:$A,">="&J2,$A:$A,"<="&K2)
N2:N4N2=MAXIFS(E:E,A:A,">="&J2,A:A,"<="&K2)
H2:H12H2=PERCENTILE($E$2:$E$1644,G2)
 
Upvote 1

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Dear Jeffrey
Will read your reply tomorrow morning. Have a good night.
 
Upvote 0
Thanks a lot. My data are 50 years from 1971 to 2021.
Let me read tomorrow and reach you.
Again thanks for all your valuable support.
 
Upvote 0
OK, so I tweaked the Contiguous Wet Days column. It now only shows one number per set of wet days. This will improve your stats. I changed my date ranges to reflect a water year that the agencies use in their calculations; usually by the USGS.

I altered the Count columns in the stat area. "Count >=" shows the count of wet days greater than or equal to the provided value. "Count =" shows the count of wet days equal to the provided value. I also added "Min > 0" which shows the minimum wet days over zero.

Yabi100.xlsm
ABCDEFGHIJKLM
1DateRainfall (mm)YearWet DaysContiguous Wet DaysFirst DateLast DateWet DaysCount >=Count =MaxMin > 0
21/1/202072020FALSE010/1/20209/30/20217612607
31/2/202002020FALSE010/1/20219/30/20221271674
41/3/2020312020TRUE1310/1/20229/30/202320601031
51/4/202082020TRUE0
61/5/2020382020TRUE0
71/6/2020312020TRUE0
81/7/2020272020TRUE0
91/8/202012020TRUE0
101/9/2020362020TRUE0
111/10/2020252020TRUE0
121/11/202042020TRUE0
131/12/2020112020TRUE0
141/13/2020272020TRUE0
151/14/202092020TRUE0
161/15/2020192020TRUE0
171/16/202032020FALSE0
181/17/202002020FALSE0
191/18/202032020TRUE10
201/19/2020382020TRUE0
211/20/202082020TRUE0
221/21/2020122020TRUE0
231/22/2020332020TRUE0
241/23/2020292020TRUE0
251/24/202032020TRUE0
261/25/2020382020TRUE0
271/26/202092020TRUE0
281/27/2020232020TRUE0
291/28/2020222020FALSE0
301/29/202002020FALSE0
311/30/2020102020TRUE21
321/31/202082020TRUE0
332/1/2020182020TRUE0
342/2/2020142020TRUE0
352/3/2020382020TRUE0
362/4/2020272020TRUE0
372/5/2020352020TRUE0
382/6/2020322020TRUE0
392/7/2020122020TRUE0
402/8/2020242020TRUE0
412/9/2020302020TRUE0
422/10/2020102020TRUE0
432/11/2020342020TRUE0
442/12/2020262020TRUE0
452/13/2020362020TRUE0
462/14/2020272020TRUE0
472/15/2020102020TRUE0
482/16/2020322020TRUE0
492/17/202022020TRUE0
502/18/2020112020TRUE0
512/19/2020292020TRUE0
522/20/2020342020FALSE0
532/21/202002020FALSE0
542/22/202032020TRUE10
552/23/2020192020TRUE0
562/24/2020162020TRUE0
572/25/2020362020TRUE0
582/26/202042020TRUE0
592/27/2020302020TRUE0
602/28/2020332020TRUE0
612/29/202072020TRUE0
623/1/2020302020TRUE0
633/2/2020202020TRUE0
643/3/2020352020FALSE0
653/4/202002020FALSE0
663/5/2020122020TRUE49
673/6/2020232020TRUE0
683/7/2020142020TRUE0
693/8/202082020TRUE0
703/9/2020172020TRUE0
713/10/2020312020TRUE0
723/11/2020152020TRUE0
733/12/202032020TRUE0
743/13/2020332020TRUE0
Sheet1
Cell Formulas
RangeFormula
C2:C74C2=YEAR(A2)
D2:D74D2=AND(B2>=1,SUMIFS(B:B,A:A,A2+1,B:B,">="&1))
E2:E74E2=IF(AND(D2=TRUE,$D1=FALSE),COUNTA(OFFSET($D2,0,0,MATCH(FALSE,$D2:$D$1000000,0)-1,1)),0)
J2:J4J2=COUNTIFS($E:$E,">="&$I2,$A:$A,">="&$G2,$A:$A,"<="&$H2)
K2:K4K2=COUNTIFS($E:$E,"="&$I2,$A:$A,">="&$G2,$A:$A,"<="&$H2)
L2:L4L2=MAXIFS($E:$E,$A:$A,">="&$G2,$A:$A,"<="&$H2)
M2:M4M2=MINIFS($E:$E,$E:$E,">"&0,$A:$A,">="&$G2,$A:$A,"<="&$H2)
 
Upvote 0
Here another option. Is this what you need?:
Data extends till row 18629.
Question is what happens if you have a wet period just between 2 years. Lets say it starts to rain on the 28 of December and it rains till 3 of January (inclusive).
What the "# of wet periods" formula currently does is count the period as of 1972.
And the "# of days of longest wet period" would show 4 if it would be the longest wet period in 1971, and 7 for 1972.

1722523231453.png


Book6.xlsx
ABCDEFGH
1DateRainfall [mm]Helper column 1Helper column 2Year# or wet periods (2 or more consecutive days of 1 mm or more)# of days of the longest wet period
201/01/1971---1971346
302/01/1971---1972346
403/01/197125,6111973377
504/01/1971---1974304
605/01/1971---1975457
706/01/197173,6111976308
807/01/1971---1977315
908/01/1971---1978446
1009/01/197139,2111979358
1110/01/1971---1980324
1211/01/1971---1981384
1312/01/1971---1982384
1413/01/1971---1983336
1514/01/1971---1984294
1615/01/197168,6111985356
1716/01/1971---1986296
1817/01/1971---1987357
1918/01/1971---1988335
2019/01/1971---1989388
2120/01/197116,61-1990376
2221/01/19719,9221991406
2322/01/1971---1992276
2423/01/1971---1993327
2524/01/197152,5111994354
2625/01/1971---1995336
2726/01/1971---1996407
2827/01/197141,6111997315
2928/01/1971---1998308
3029/01/1971---1999345
3130/01/197129,8112000326
3231/01/1971---2001365
3301/02/1971---2002335
3402/02/1971---2003384
3503/02/1971---2004395
3604/02/197116,7112005326
3705/02/1971---2006396
3806/02/1971---2007325
3907/02/1971---2008355
4008/02/197135,7112009397
4109/02/1971---2010386
4210/02/197173,1112011378
4311/02/1971---2012415
4412/02/1971---2013306
4513/02/1971---2014307
4614/02/1971---2015304
4715/02/197146,4112016347
4816/02/1971---20173511
4917/02/1971---2018346
5018/02/1971---2019386
5119/02/1971---2020358
5220/02/1971---2021315
5321/02/1971---
5422/02/1971---
5523/02/19714,21-
5624/02/197127,222
5725/02/1971---
5826/02/197176,61-
5927/02/197146,322
6028/02/1971---
6101/03/1971---
Sheet1
Cell Formulas
RangeFormula
C2:C61C2=IF((B2>=1), N(C1)+1, 0)
D2:D61D2=C2*(C3=0)
G2:G52G2=SUM((YEAR($A$2:$A$18629)=F2)*($D$2:$D$18629>1))
H2:H52H2=MAX((YEAR($A$2:$A$18629)=F2)*($C$2:$C$18629))
 
Upvote 1
The formula I have in column already accounts for years. See the example below with November 30 starting a 38 day wet period


Yabi100.xlsm
ABCDE
1DateRainfall (mm)YearWet DaysContiguous Wet Days
33511/29/202002020FALSE0
33611/30/2020182020TRUE38
33712/1/202032020TRUE0
33812/2/202052020TRUE0
33912/3/2020322020TRUE0
34012/4/2020272020TRUE0
34112/5/2020162020TRUE0
34212/6/2020302020TRUE0
34312/7/2020382020TRUE0
34412/8/202032020TRUE0
34512/9/202032020TRUE0
34612/10/2020192020TRUE0
34712/11/2020192020TRUE0
34812/12/2020182020TRUE0
34912/13/2020302020TRUE0
35012/14/2020112020TRUE0
35112/15/2020212020TRUE0
35212/16/202062020TRUE0
35312/17/2020212020TRUE0
35412/18/2020262020TRUE0
35512/19/2020132020TRUE0
35612/20/2020132020TRUE0
35712/21/2020192020TRUE0
35812/22/2020162020TRUE0
35912/23/2020102020TRUE0
36012/24/2020292020TRUE0
36112/25/2020202020TRUE0
36212/26/2020172020TRUE0
36312/27/2020272020TRUE0
36412/28/2020242020TRUE0
36512/29/202022020TRUE0
36612/30/202012020TRUE0
36712/31/2020362020TRUE0
3681/1/2021212021TRUE0
3691/2/2021372021TRUE0
3701/3/2021232021TRUE0
3711/4/2021312021TRUE0
3721/5/2021282021TRUE0
3731/6/2021292021TRUE0
3741/7/2021102021FALSE0
3751/8/202102021FALSE0
3761/9/202172021TRUE56
3771/10/2021312021TRUE0
3781/11/2021312021TRUE0
3791/12/202112021TRUE0
3801/13/202182021TRUE0
3811/14/2021282021TRUE0
3821/15/2021132021TRUE0
3831/16/2021142021TRUE0
3841/17/202122021TRUE0
3851/18/2021322021TRUE0
3861/19/202182021TRUE0
3871/20/2021252021TRUE0
3881/21/202192021TRUE0
3891/22/2021262021TRUE0
3901/23/202152021TRUE0
3911/24/2021122021TRUE0
3921/25/2021102021TRUE0
3931/26/2021122021TRUE0
3941/27/2021362021TRUE0
3951/28/2021372021TRUE0
3961/29/2021152021TRUE0
3971/30/2021262021TRUE0
3981/31/2021142021TRUE0
Sheet1
Cell Formulas
RangeFormula
C335:C398C335=YEAR(A335)
D335:D398D335=AND(B335>=1,SUMIFS(B:B,A:A,A335+1,B:B,">="&1))
E335:E398E335=IF(AND(D335=TRUE,$D334=FALSE),COUNTA(OFFSET($D335,0,0,MATCH(FALSE,$D335:$D$1000000,0)-1,1)),0)
Named Ranges
NameRefers ToCells
_FilterDatabase=Sheet1!$A$1:$E$1644D335:D398
Print_Area=Sheet1!$A$1:$E$1644D335:D398
 
Upvote 1
Dear Felix
Thank you very much for your very genius solution. Accept my appology if this is a basic question, but I couldn't understand the meaning of the formula in D2, that is =C2*(C3=0). I am using Excel for a long time, but this is the first time I am seeing such a formula. I even don't know the name this type of formula to search in Google. Will be very happy to read a short note for this formula and it's name. Althought I admit, what ever it is, it is a great formula and the result is what I am exactly looking for.
 
Upvote 0
Dear Jeffrey
Thanks for your reply. I haven't checked your answer yet, but it seams it is doing what I want. Let me check it and come bck again. I appreciate your time and effort to answer to my question.
 
Upvote 0
You mentioned:
Question is what happens if you have a wet period just between 2 years. Lets say it starts to rain on the 28 of December and it rains till 3 of January (inclusive).
What the "# of wet periods" formula currently does is count the period as of 1972.
And the "# of days of longest wet period" would show 4 if it would be the longest wet period in 1971, and 7 for 1972.

This is a real question but for the time being, it is not my concern. My professor asked me to zoom on "years" at this moment. Maybe this will be the next subject to tackle.
 
Upvote 0
the meaning of the formula in D2, that is =C2*(C3=0)

Hi Yabi100.
Excel Formula:
C3 = 0
Checks if C3 is equal to 0, and it returns TRUE or FALSE. But if you multiply this boolean result by any number it turns the TRUE into 1 and FALSE into 0.
So basically we check if the next day there has been rainfall and if so we take the number from C2. That is we get only the max value from every wet period.

It would be the same as

Excel Formula:
IF(C3=0, C2, 0)

Hope this makes sense.
 
Upvote 1

Forum statistics

Threads
1,223,869
Messages
6,175,087
Members
452,611
Latest member
bls2024

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