+ Reply to Thread
Results 1 to 8 of 8

Find the longest run of 0's in a column

  1. #1
    Registered User
    Join Date
    11-10-2008
    Location
    Melbourne
    Posts
    4

    Smile Find the longest run of 0's in a column

    Hi guys - new to this forum.

    I have searched for this and cant find a previous solution.

    I have a list of dates in column A (sequential from low to high).
    I have corresponding rainfall data in column S.

    I am trying to find the longest run of 0's in the rainfall data and return the start and end dates. It would be great if i could tell it (in cell C8) to find the longest run below this number.
    ie: i say i want to find the longest run of numbers below 5.

    I think the answer may be in an array formula but i dont know too much about them.

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    08-26-2008
    Location
    singapore
    Posts
    626
    How about give us a sample file or some data range
    I need your support to add reputations if my solution works.


  3. #3
    Registered User
    Join Date
    11-10-2008
    Location
    Melbourne
    Posts
    4
    Column A data
    1/01/1987
    2/01/1987
    3/01/1987
    4/01/1987
    5/01/1987
    6/01/1987
    7/01/1987
    8/01/1987
    9/01/1987
    10/01/1987
    11/01/1987
    12/01/1987
    13/01/1987
    14/01/1987
    15/01/1987
    16/01/1987
    17/01/1987
    18/01/1987
    19/01/1987
    20/01/1987
    21/01/1987
    22/01/1987
    23/01/1987
    24/01/1987
    25/01/1987
    26/01/1987
    27/01/1987
    28/01/1987
    29/01/1987
    30/01/1987
    31/01/1987
    1/02/1987
    2/02/1987
    3/02/1987
    4/02/1987
    5/02/1987
    6/02/1987
    7/02/1987
    8/02/1987
    9/02/1987
    10/02/1987
    11/02/1987
    12/02/1987
    13/02/1987
    14/02/1987
    15/02/1987
    16/02/1987
    17/02/1987
    18/02/1987
    19/02/1987
    20/02/1987
    21/02/1987
    22/02/1987
    23/02/1987
    24/02/1987
    25/02/1987
    26/02/1987
    27/02/1987
    28/02/1987

    Column S data
    0.4
    0
    33.2
    12.2
    2.2
    2
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    1.2
    2
    0
    2.2
    1.8
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0
    0.2
    0
    0
    0
    0
    0
    0.2
    0
    0
    0
    0
    3.6
    40
    0.2
    0
    0
    1.6
    0
    0
    11.4

    Hope that helps.

    (Thanks for the quick reply).

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    well that wins the prize for longest post i think a worksheet might actually be better !

  5. #5
    Registered User
    Join Date
    11-10-2008
    Location
    Melbourne
    Posts
    4
    hahaha - i couldnt work out how to attach it.

    sorry!!

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    There's a button that looks like a paperclip in the toolbar above the reply box. Push it, browse to the file, and press the Upload button.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Assuming that A2:A60 contains the date, and S2:S60 contains the corresponding data, try the following...

    For the longest run of 0's...

    T2, copied down:

    =IF($S2=0,SUM(T1,1),0)

    W2:

    =MAX(T2:T60)

    X2:

    =INDEX($A$2:$A$60,MATCH(W2,$T$2:$T$60,0)-W2+1)

    Y2:

    =INDEX($A$2:$A$60,MATCH(W2,$T$2:$T$60,0))

    For the longest run of numbers below 5...

    U2, copied down:

    =IF($S2<5,SUM(U1,1),0)

    W4:

    =MAX(U2:U60)

    X4:

    =INDEX($A$2:$A$60,MATCH(W4,$U$2:$U$60,0)-W4+1)

    Y4:

    =INDEX($A$2:$A$60,MATCH(W4,$U$2:$U$60,0))

    See the attached file...

    Hope this helps!
    Attached Files Attached Files
    Last edited by Domenic; 11-10-2008 at 11:19 PM. Reason: Added formula for U2, copied down...

  8. #8
    Registered User
    Join Date
    11-10-2008
    Location
    Melbourne
    Posts
    4

    Talking Thanks....

    Spot on Domenic - i didnt think of doing it in another column and like your methodology.

    I was overcomplicating it - trying to do in one formula - thanks for your logic.

    Now if you can fix my watch ill be very impressed.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1