+ Reply to Thread
Results 1 to 8 of 8

Running totals in column

  1. #1
    Registered User
    Join Date
    04-10-2010
    Location
    Pittsburgh PA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Running totals in column

    Hello all. I'm very (very ) new to Excel. I come from the MySql/PHP world so my question is about what's possible to with this program.

    More specifically I have two columns. Column A is date. Column B is a result. There can be only two results X or Y. So it looks like this:

    1/1/10 X
    1/2/10 Y
    1/3/10 Y
    1/4/10 Y
    1/5/10 X

    What I'd like to do is have a third column keep a running total if X = +1, and Y = -1. So ideally the result would look like this:

    1/1/10 X +1
    1/2/10 Y 0
    1/3/10 Y -1
    1/4/10 Y -2
    1/5/10 X -1

    and so on ...

    Is this possible in excel, and where would I begin? Thanks very much.

  2. #2
    Valued Forum Contributor
    Join Date
    10-06-2008
    Location
    Norway
    MS-Off Ver
    2010
    Posts
    365

    Re: Running totals in column

    If the first date is in A1, C1: =IF(B1="X",1,-1)
    C2 and copy down: =IF(B2="X",C1+1,C1-1)

  3. #3
    Registered User
    Join Date
    04-10-2010
    Location
    Pittsburgh PA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Running totals in column

    Thank you replying. I'll try that now and see what I get.

  4. #4
    Registered User
    Join Date
    04-10-2010
    Location
    Pittsburgh PA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Running totals in column

    That works brilliantly. Thanks! One more question - Can I say If B1 starts with X, rather than equals X?

  5. #5
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Running totals in column

    Assuming your data start in row 2

    C2: =C1+(B2="X")-(B2="Y")

    copy down as far as needed

  6. #6
    Registered User
    Join Date
    04-10-2010
    Location
    Pittsburgh PA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Running totals in column

    Ok. I've almost go this figured out thanks to this forum. I have the following formula:

    =IF(LEFT(B3)="X",C2+1,C2-1)

    How would say the following (if there is a third result other than X or Y)?

    If B3 starts with X, add one to C2, if B3 starts with Y, subtract one from C2, otherwise add zero (or keep C3 the same as C2).

  7. #7
    Valued Forum Contributor
    Join Date
    10-06-2008
    Location
    Norway
    MS-Off Ver
    2010
    Posts
    365

    Re: Running totals in column

    =if(left(b3)="X",c2+1,if(left(b3)="Y",c2-1,c2))

  8. #8
    Registered User
    Join Date
    04-10-2010
    Location
    Pittsburgh PA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Running totals in column

    Perfect! Thanks very much Estige. And this forum.

+ 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