Interval accumulation and resets

T

Tom

WinXP Pro SP2
Excel 2003 SP3

I am trying to create an Excel formula that totals the interval values as
they decrease or as they increase. Upon a change of direction (SIGN(),
probably) I want to reset/restart the accumulation.
Here's my current attempt but it's probably not too close.
=IF(SIGN($D33)=SIGN($D32),$D33-$D32,0)
Column D is the change of the value of an average (mean) measurement for
column C.
Here's a sample
Row Col C Col D
1 361193
2 360566 -627
3 350680 -9886
4 327803 -22877
5 317173 -10630
As Col D continues to decrease then I need to accumulate the 'negative'
values. Once Col D gets a positive value, which indicates a change of
direction, then I need to start accumulating the values so that I start with
the first value. I don't want to have a SUM() of the accumulation for all
the Col D values. I just want the sum of the values as long as the sign of
Col D is the same.
So, as long as Col C decreases, I need to accumulate during the entire
'series'. Once Col D changes to increasing, I need to accumulate during the
entire 'series' and then reset/restart when Col D changes to
negative/decreases.
TIA!
Tom
 
H

Herbert Seidenberg

Assume your List looks like this:
List Accu SignC
-12 0 0
-5 7 1
24 36 1
35 47 1
-48 0 0
-46 2 0
-40 8 1
-34 14 1
-29 19 1
-46 0 0
40 86 0
50 96 1
18 0 0
-18 -36 1
18 0 0
24 6 1
37 19 1
40 22 1
Add two columns, named Accu and SignC
Into cell 1, 2 of SignC, enter 0, 1 respectively
into cell 3 of SignC enter this formula and copy down
=--(SIGN(List R-List R[-1])=SIGN(List R[-1]-List R[-2]))
Into cell 1 of Accu, enter 0
Into cell 2 of Accu enter and copy down
=IF(SignC,List R-List R[-1]+Accu R[-1],
IF(Accu R[-1]=0,List R-List R[-1]+Accu R[-1],0))
Formulas written in
Tools > Options > General > R1C1
for intuitive readability.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top