+ Reply to Thread
Results 1 to 9 of 9

MAX Consecutive across columns

Hybrid View

  1. #1
    Registered User
    Join Date
    03-31-2010
    Location
    Portland, OR
    MS-Off Ver
    Excel 2007
    Posts
    38

    MAX Consecutive across columns

    Hello everyone.
    I would really appreciate some help on this one - here is what I need to figure out (see attached .xlsx file)

    In E209, I need an array that will count MAX consecutive wins ongoing throughout time. And in E210, to count MAX consecutive losses (less than$0). The issue I have is that the wins (a win being any value greater than 0), are located on each daily row and in columns I,Q,Y,AG,AO,AW, and BE. After column BE ,it should again look to the next row and continue the MAX count at column I all the way down. Since there is a blank row every 5th row, it will need to skip that row, or not count blank values. Also, if the columns I need it to look at have a value of $0, i need it to disregard counting it but without resetting the MAX count.

    I know I could have physically counted this myself in the time I could have solved this problem but I would rather figure out the correct way to write this array.

    Any help would be much appreciated!!!

    William
    Attached Files Attached Files

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,325

    Re: MAX Consecutive across columns

    Find the attached with two User Defined Functions
    1. MaxWinCounter()
    2. MaxLossCounter()

    To use these you will need to select a range (single column please) and it will do your counting.

    See cells I209 and I210 for the examples.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    03-31-2010
    Location
    Portland, OR
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: MAX Consecutive across columns

    Marvin.
    Thanks! I take it these results are done with a macro? I do not see the macro there but the results are correct. Can you elaborate a bit more on how this works? Are there other options for coming up with the same information using an array?
    Thanks.
    William
    Last edited by shg; 08-25-2010 at 11:49 PM. Reason: deleted spurious quote

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: MAX Consecutive across columns

    William, please don't quote whole posts -- it's just clutter.

    Press the REPLY button, not the QUOTE button.

    Thanks.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: MAX Consecutive across columns

    Quote Originally Posted by williampdx
    Are there other options for coming up with the same information using an array?
    Realistically given your data you would need to create a contiguous listing and work from that.

    Using your sample file... insert a new sheet, name it "Data" and add following headers:

    A1: Date
    B1: +/-
    C1: Sign
    Then

    A2:
    =IF(MOD(ROWS(A$2:A2)-1,7),A1,INDEX('COR Table'!$B:$B,3+CEILING(ROWS(A$2:A2)/7,1)+CEILING(ROWS(A$2:A2)/35,1)-1))
    
    B2:
    =INDEX('COR Table'!$A:$BF,3+CEILING(ROWS(A$2:A2)/7,1)+CEILING(ROWS(A$2:A2)/35,1)-1,9+8*MOD(ROWS(A$2:A2)-1,7))
    
    C2:
    =IF(B2=0,N(C1),SIGN(B2))
    
    copy A2:C2 down to row 1191 (to cover your 1190 data points)
    With the above in place your "streak" calculations can be based off the above data set with relative ease:

    Wins:
    =MAX(FREQUENCY(IF(Data!$C$2:$C$1191=1,ROW(Data!$C$2:$C$1191)),IF(Data!$C$2:$C$1191<1,ROW(Data!$C$2:$C$1191))))
    confirmed with CTRL + SHIFT + ENTER
    
    Losses (as above but using -1 and > test):
    =MAX(FREQUENCY(IF(Data!$C$2:$C$1191=-1,ROW(Data!$C$2:$C$1191)),IF(Data!$C$2:$C$1191>-1,ROW(Data!$C$2:$C$1191))))
    confirmed with CTRL + SHIFT + ENTER
    Based on the sample data I believe the answer for both calculations is 24, correct ?

  6. #6
    Registered User
    Join Date
    03-31-2010
    Location
    Portland, OR
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: MAX Consecutive across columns

    Actually, the answer for consecutive losses is 12, and consecutive wins is 15. Your solution would work, but I need a solution that will not require the addition of another worksheet. It really is essential I keep the worksheets to a minimum and can have an ongoing total on the same COR TABLE sheet. Any other ways to do this??

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,325

    Re: MAX Consecutive across columns

    I've cleaned my code a bit but believe it is yoiur easiest answer.
    You will need to use the User Defined Function and select the range (rows in a single column) that you are counting. Find all answers on the attached with a cleaner UDF.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    03-31-2010
    Location
    Portland, OR
    MS-Off Ver
    Excel 2007
    Posts
    38

    Re: MAX Consecutive across columns

    So there is no way to do this with a simple array and not run a macro?

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: MAX Consecutive across columns

    As a general rule we try to offer the most efficient approach open to you - if a simple formula were available it would most likely have been provided.
    (note: most likely - I am not asserting that it is not beyond the realms of possibility - perhaps a convoluted frequency array)

    Working with non-contiguous data sets is generally inefficient - doing so where there is an irregular pattern within the non-contiguous set is (understandably) even less efficient.

    Work with contiguous data sets - if you're not willing/prepared/able to do that then use a UDF (I've not looked at that offered to you already so am not passing comment on the specifics).

    As for the expected results being 15 (wins) and 12 (losses) -I confess I'm slightly confused - either the 0's interspersed amongst the winning streak add to the appropriate streak or they do not ?

    If the zeroes neither reset the streak nor add to its longevity then I make the longest winning streak 11 - such a streak occurs on 2 occasions:

    2nd July 2010 GBP/JPY to 7th July 2010 GBP/JPY inclusive.
    20th August 2010 GBP/JPY to 24th August 2010 EUR/USD inclusive

    Else the streak is seemingly greater than 11 (ie the 0s interspersed amongst the positive values increment the streak)

    If you stand by the 15 perhaps you could specify the data points involved ?
    Last edited by DonkeyOte; 08-27-2010 at 03:28 AM. Reason: typo in narrative

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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