View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
T. Valko T. Valko is offline
external usenet poster
 
Posts: 15,768
Default Find longest consecutive winning streaks

Using a single array formula** entered in, say, E1:

=LARGE(FREQUENCY(IF(B$1:B$460,ROW(B$1:B$46)),IF(B $1:B$46<=0,ROW(B$1:B$46))),ROWS(E$1:E1))

Copy down until you get either 0s or #NUM! errors.

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER)

--
Biff
Microsoft Excel MVP


"Gary''s Student" wrote in message
...
We know a streak has ended if we have a positive value followed by a zero.
So in D1 enter:
=IF(AND((C10),(C2=0)),C1,"") and copy down. We now see:

Jan-07 1.37% 1
Feb-07 0.99% 2
Mar-07 0.12% 3 3
Apr-07 -0.45% 0
May-07 -0.18% 0
Jun-07 0.30% 1 1
Jul-07 -0.21% 0
Aug-07 0.38% 1
Sep-07 0.74% 2
Oct-07 0.37% 3
Nov-07 1.50% 4
Dec-07 1.40% 5
Jan-07 0.39% 6
Feb-07 1.44% 7 7
Mar-07 -0.09% 0
Apr-07 -0.74% 0
May-07 0.88% 1
Jun-07 1.31% 2
Jul-07 1.53% 3
Aug-07 0.82% 4
Sep-07 1.63% 5 5
Oct-07 -1.50% 0
Nov-07 1.59% 1
Dec-07 1.93% 2
Jan-07 2.76% 3
Feb-07 0.47% 4
Mar-07 0.93% 5
Apr-07 1.63% 6 6
May-07 -1.65% 0
Jun-07 -0.68% 0
Jul-07 -0.03% 0
Aug-07 0.84% 1
Sep-07 0.28% 2
Oct-07 1.24% 3
Nov-07 1.52% 4
Dec-07 1.35% 5
Jan-07 1.44% 6
Feb-07 0.83% 7
Mar-07 1.58% 8
Apr-07 1.73% 9
May-07 1.91% 10
Jun-07 0.90% 11
Jul-07 1.01% 12 12
Aug-07 -1.38% 0
Sep-07 2.05% 1
Oct-07 2.83% 2 2

So now the 12 is still the highest, 7 is the next highest, etc. This
method
will also display ties.
--
Gary''s Student - gsnu200761


"trey1982" wrote:

How can I create a formula that looks for the next lower value followed
by a
zero to find the end of the next longest streak?

thanks...trey


"Gary''s Student" wrote:

In C1 enter 1
In C2 enter:
=IF(B20,C1+1,0) and copy down. We see:

Jan-07 1.37% 1
Feb-07 0.99% 2
Mar-07 0.12% 3
Apr-07 -0.45% 0
May-07 -0.18% 0
Jun-07 0.30% 1
Jul-07 -0.21% 0
Aug-07 0.38% 1
Sep-07 0.74% 2
Oct-07 0.37% 3
Nov-07 1.50% 4
Dec-07 1.40% 5
Jan-07 0.39% 6
Feb-07 1.44% 7
Mar-07 -0.09% 0
Apr-07 -0.74% 0
May-07 0.88% 1
Jun-07 1.31% 2
Jul-07 1.53% 3
Aug-07 0.82% 4
Sep-07 1.63% 5
Oct-07 -1.50% 0
Nov-07 1.59% 1
Dec-07 1.93% 2
Jan-07 2.76% 3
Feb-07 0.47% 4
Mar-07 0.93% 5
Apr-07 1.63% 6
May-07 -1.65% 0
Jun-07 -0.68% 0
Jul-07 -0.03% 0
Aug-07 0.84% 1
Sep-07 0.28% 2
Oct-07 1.24% 3
Nov-07 1.52% 4
Dec-07 1.35% 5
Jan-07 1.44% 6
Feb-07 0.83% 7
Mar-07 1.58% 8
Apr-07 1.73% 9
May-07 1.91% 10
Jun-07 0.90% 11
Jul-07 1.01% 12
Aug-07 -1.38% 0
Sep-07 2.05% 1
Oct-07 2.83% 2

Look for the max in column C (12) to find the end of the longest
streak,
then look for the next lower value followed by a zero to find the end
of the
next longest streak, etc.

--
Gary''s Student - gsnu200761


"trey1982" wrote:

My data set is a series of monthly returns (in percentages) for an
investment. How can I go about finding which time period has the
longest
consecutive winning months and what the return over that time period
was.
Then find the second and third longest winning streaks which cannot
be
contained in the longest one.

thanks in advance... trey

Jan-04 1.37%
Feb-04 0.99%
Mar-04 0.12%
Apr-04 -0.45%
May-04 -0.18%
Jun-04 0.30%
Jul-04 -0.21%
Aug-04 0.38%
Sep-04 0.74%
Oct-04 0.37%
Nov-04 1.50%
Dec-04 1.40%
Jan-05 0.39%
Feb-05 1.44%
Mar-05 -0.09%
Apr-05 -0.74%
May-05 0.88%
Jun-05 1.31%
Jul-05 1.53%
Aug-05 0.82%
Sep-05 1.63%
Oct-05 -1.50%
Nov-05 1.59%
Dec-05 1.93%
Jan-06 2.76%
Feb-06 0.47%
Mar-06 0.93%
Apr-06 1.63%
May-06 -1.65%
Jun-06 -0.68%
Jul-06 -0.03%
Aug-06 0.84%
Sep-06 0.28%
Oct-06 1.24%
Nov-06 1.52%
Dec-06 1.35%
Jan-07 1.44%
Feb-07 0.83%
Mar-07 1.58%
Apr-07 1.73%
May-07 1.91%
Jun-07 0.90%
Jul-07 1.01%
Aug-07 -1.38%
Sep-07 2.05%
Oct-07 2.83%