+ Reply to Thread
Results 1 to 2 of 2

Conditional Summation

  1. #1
    Registered User
    Join Date
    11-17-2010
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    3

    Conditional Summation

    A few days ago I solicited a solution to a problem I have by posting:
    I have a spreadsheet that represents stock daily data and associated trades in rows. As with all trading, some trades are winners and some losers and on some days, there are no trades, as represented by "0". Winners are identified in a column by a "1" and losers by a "-1". I need a formula that will sum the largest number of consecutive winners and losers.
    A very helpful individual replied to my question and provided me with the following message:

    You can use an Array

    Code:
    Longest Winning Streak:

    =MAX(FREQUENCY(IF(A2:A200=1,ROW(A2:A200)),IF(A2:A200<>1,ROW(A2:A200))))
    confirmed with CTRL + SHIFT + ENTER (enter alone will not suffice)

    Modify ranges as nec. but try to keep as lean as possible

    above assumes 0's (like -1's) stop the winning streak ... for losing streak change references to 1 to -1


    Unfortunately, this response didn’t solve my problem because the column values look something like “1,0,0,1,0,0,1,1”. Since "0" stops the streak the supplied solution will not work. Help please.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Conditional Summation

    This comment:

    above assumes 0's (like -1's) stop the winning streak ... for losing streak change references to 1 to -1
    is what you said:

    Since "0" stops the streak ....
    Did you remember to confirm the formula with CTRL+SHIFT+ENTER and not just ENTER. You will see { } brackets appear around the formula.

    It worked for me.. I got 2 for tha last 2 1's in a row.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

+ 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