+ Reply to Thread
Results 1 to 9 of 9

Running total that outputs 0 if the sum is negative, and resets running total on next row.

  1. #1
    Registered User
    Join Date
    07-13-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    3

    Running total that outputs 0 if the sum is negative, and resets running total on next row.

    Hi there,

    I am trying to create a formula that calculates the running total of column A.

    However, when the running total is negative, two things should happen:
    1. The output should be zero.
    2. The running total should start anew on the next row.

    And most importantly... the formula cannot use column B as a reference.

    Is this possible with one fluid formula? The formula would need to account for future values, so there may be multiple "resets".

    Any help is appreciated!
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Running total that outputs 0 if the sum is negative, and resets running total on next

    The "not use column B" as a reference is non-sensical. The simplest way to do a running total is transactionally, adding the new transaction to the old "total". I've done it this way for years for non-negative running totals, the formula in B2, then copied down would be:

    =MAX(0, A2+N(B1))

    This gives the exact desired results.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-13-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    3

    Re: Running total that outputs 0 if the sum is negative, and resets running total on next

    Yes, that does achieve the desired result (I actually used this exact formula when i first solved). However nonsensical the rules may be, they are there for a reason.

    In this case, the means to the end is more important than the end itself. If you can find a way to replicate the goal within the guidelines, please post it here!

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,448

    Re: Running total that outputs 0 if the sum is negative, and resets running total on next

    You obviously have your reasons, but it would be helpful to know why column B must not be used in the formula.

    OK - devil's advocate here:

    1. In D2, type =B2 - copy down.
    2. Hide column D.
    3. In C2, type =MAX(0, A2+N(D1)) - copy down.

    How's that?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    07-13-2017
    Location
    US
    MS-Off Ver
    2013
    Posts
    3

    Re: Running total that outputs 0 if the sum is negative, and resets running total on next

    It's very close, but the sum doesn't seem to reset. It will result in a "0" for any negative values.

    Here's what I show: 2,6,4,0,0,0,0,5,0,0,0

    If it would help to know the reason for the formula being unable to reference itself, I am happy to explain! I am trying to solve this problem in a way that uses concepts which will be important later when using power pivot and power bi. In this problem, the formulas cannot reference themselves.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,448

    Re: Running total that outputs 0 if the sum is negative, and resets running total on next

    OK - but the formula would not be referencing itself, so I'm still not clear. However, I'll see if I can think of another way.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Running total that outputs 0 if the sum is negative, and resets running total on next

    It would be interesting as well to understand how Power Pivot is affected by the method the column B values use to calculate? All of my understanding of pivot tables is that they operate on the values in the source data, the underlying formulas irrelevant.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,448

    Re: Running total that outputs 0 if the sum is negative, and resets running total on next

    Try this, please, in C2 drag copied down:

    =IF(SUM(C1,A2)<0,0,SUM(C1,A2))

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,448

    Re: Running total that outputs 0 if the sum is negative, and resets running total on next

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Running total from a daliy worksheet into a montly total.
    By jakesib in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-15-2014, 10:49 PM
  2. Pivot Chart Running Total - Removing Current Year Future Total
    By car3489 in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 07-27-2013, 03:35 AM
  3. Replies: 2
    Last Post: 01-18-2013, 11:47 AM
  4. calculating the total from a running totalizer that resets
    By superchill435 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-10-2012, 11:04 AM
  5. Running Total and Resets
    By HyMay1180 in forum Excel General
    Replies: 11
    Last Post: 04-20-2011, 03:49 PM
  6. Running total of multiple running totals
    By ashncg in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-09-2011, 05:20 PM
  7. [SOLVED] % of Running Total to Grand Total in Pivot Table
    By David in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-17-2005, 04:05 PM

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