Page 1 of 1

Results accumulation

Posted: Fri Jul 07, 2006 7:06 pm
by KCL
Hi,

Is there a predefined function in Vensim that accumulates the results of an auxiliary variable over time? Suppose I have an auxiliary variable called Net Sales. How do I accumulate Net Sales in an auxiliary variable Net Sales To-Date?

EX.
If Net Sales for 3 periods are $5, $10, and $20, then
Net Sales To-Date for the 3 periods should be $5, $15, and $35.

Also, how do you reset Net Sales To-Date? Let's say Net Sales is $7 in the period 4 and I want Net Sales To-Date to reset at the start of the quarter. So, instead of $42, Net Sales To-Date would be $7 in the 4th period of this scenario .

I would greatly appreciate any help that points me in the right direction.

Thanks, Ken

Posted: Sat Jul 08, 2006 11:37 am
by bob@vensim.com
most basically

cum sales = INTEG(sales,0)

to reset

cum sales with reset = INTEG(sales - reset,0)
reset = IF THEN ELSE(MODULO(Time,time periods per quarter) = 0,cum sales with reset/TIME STEP,0)

and if you want to get this period's sales

cum sales including this period = cum sales with reset + sales * TIME STEP

Posted: Tue Jul 11, 2006 2:33 pm
by KCL
Bob, thank you so much. This is great help.