Count number of days between start and end of drawdown

aiki100

Board Regular
Joined
Aug 16, 2016
Messages
102
Greetings All and a very Happy New Year to you and yours everywhere!

Could use some help please:

I am trying to count the number of days the between the start and end of a drawdown. i.e., how long did the drawdown last (in calendar days), before the state of drawdown ceased to exist?

I have tried several permutations (between me and Google) and it is still not correct, (and is likely not he best way to proceed anyway). There is probably a better way I imagine, (however I do wish to work this out without VBA, thanks).

Anyway, Here is what I have done so far:

In COL AH is a formula that counts drawdowns from another column (COL AF). When the source column shows a drawdown (<0), col AH starts counting until there is no longer a drawdown. So AH counts streaks. A 0 (zero) means there is no drawdown. Any other number, (1 and up) means this column is counting a continued streak of drawdowns.

COL AH
=IF($AF3=0,0,$AH2+1)

COL AI Looks at AH and copies dates for (each day of) the duration of the drawdown(s) from a different date column (COL M). Importantly, it does not include the date the losing streak ends, only right up until it ends.

COL AI
=IF(AH3=0,"",
IF(AND(AH3=0,AH2>=1),"",M3))

Since I could not find any better way to do this so far, COL AJ returns a date (the actual date that the drawdown ended) by asking if the COL AH has (two) zeros in a row, and leaving it blank if not.

COL AJ
=IF(AND(AH3=0,AH2>0),M3,"")

I now have a start date (and it's continuation) in COL AI and the date the drawdown (actually) ceased in COL AJ.

What I am after please is a way to count the number of days from the start, till the (actual) end of the streak (of drawdowns). I.e., how may days in the drawdown (till no more drawdowns)?

Thank you all so much for your thoughts on this - it is very much appreciated!



Cell Formulas
RangeFormula
AH3:AH61AH3=IF($AF3=0,0,$AH2+1)
AI3:AI61AI3=IF(AH3=0,"", IF(AND(AH3=0,AH2>=1),"",M3))
AJ3:AJ61AJ3=IF(AND(AH3=0,AH2>0),M3,"")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
AF:AF,AG1:AK61Cell Value<0textNO
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hi Aiki100,

You don't supply the other columns so I've just used the results in columns AH to AJ and put the results in AK.

Aiki100.xlsx
AHAIAJAK
1DDCampsDD DateDDDaysElapsed
2000 
30 
4112/6/2021 
5212/7/2021 
6312/7/2021 
7012/8/20213
80 
90 
10112/13/2021 
11212/13/2021 
12012/13/20211
130 
14112/14/2021 
15212/14/2021 
16312/15/2021 
17012/15/20212
18112/15/2021 
19212/15/2021 
20312/15/2021 
21412/15/2021 
22512/16/2021 
23612/16/2021 
24712/16/2021 
25812/19/2021 
26912/19/2021 
271012/20/2021 
281112/20/2021 
29012/20/20216
300 
31112/20/2021 
32012/20/20211
33112/20/2021 
34212/21/2021 
35312/21/2021 
36412/21/2021 
37512/21/2021 
38612/21/2021 
39712/21/2021 
40812/22/2021 
41912/22/2021 
42012/22/20213
43112/22/2021 
44012/22/20211
45112/22/2021 
46212/23/2021 
47312/23/2021 
48412/23/2021 
49012/28/20217
50112/27/2021 
51212/27/2021 
52312/28/2021 
53412/28/2021 
54512/28/2021 
55612/28/2021 
56712/28/2021 
57812/29/2021 
58912/29/2021 
591012/29/2021 
601112/29/2021 
611212/29/2021 
SAT
Cell Formulas
RangeFormula
AK2:AK61AK2=IF(AJ2>0,AJ2-INDEX($AI$1:$AI$9999,ROW()-AH1)+1,"")
 
Upvote 0
Hi Aiki100,

You don't supply the other columns so I've just used the results in columns AH to AJ and put the results in AK.

Aiki100.xlsx
AHAIAJAK
1DDCampsDD DateDDDaysElapsed
2000 
30 
4112/6/2021 
5212/7/2021 
6312/7/2021 
7012/8/20213
80 
90 
10112/13/2021 
11212/13/2021 
12012/13/20211
130 
14112/14/2021 
15212/14/2021 
16312/15/2021 
17012/15/20212
18112/15/2021 
19212/15/2021 
20312/15/2021 
21412/15/2021 
22512/16/2021 
23612/16/2021 
24712/16/2021 
25812/19/2021 
26912/19/2021 
271012/20/2021 
281112/20/2021 
29012/20/20216
300 
31112/20/2021 
32012/20/20211
33112/20/2021 
34212/21/2021 
35312/21/2021 
36412/21/2021 
37512/21/2021 
38612/21/2021 
39712/21/2021 
40812/22/2021 
41912/22/2021 
42012/22/20213
43112/22/2021 
44012/22/20211
45112/22/2021 
46212/23/2021 
47312/23/2021 
48412/23/2021 
49012/28/20217
50112/27/2021 
51212/27/2021 
52312/28/2021 
53412/28/2021 
54512/28/2021 
55612/28/2021 
56712/28/2021 
57812/29/2021 
58912/29/2021 
591012/29/2021 
601112/29/2021 
611212/29/2021 
SAT
Cell Formulas
RangeFormula
AK2:AK61AK2=IF(AJ2>0,AJ2-INDEX($AI$1:$AI$9999,ROW()-AH1)+1,"")







Thank you @ Toadstool...!

So very kind of you to set me straight (straight out of the gate) on New Years - thank you for taking the time.

Your formula worked perfectly. It did throw w #value error, so here is what I added to address that:

=IFERROR(IF(AJ2>0,AJ2-INDEX($AI$1:$AI$9999,ROW()-AH1)+1,""),"")

Could not have been done without you toadstool - Thanks again.

Hope you have a great year!
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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