Depreciate Function
Calculates how your capital investments lose value over time by spreading costs across their useful lifespans.
How does the Depreciate Function Work
Managing capital expenditures (CapEx) usually means building out complex waterfall schedules to track when assets were purchased, how long they last, and how much value they lose each month or year. The depreciate() function handles this entire matrix for you.
It takes your incoming CapEx, remembers exactly when those assets were acquired (their "vintage"), and automatically spreads the costs out over their defined useful life.
Finally, it sums up the depreciation expenses from all of your active historical vintages to give you the total depreciation expense for the current period.
Underlying Math
Arguments
The function requires two primary arrays to run, and accepts optional inputs for calculation methods, salvage values, and filtering.
CapEx (Required): The amount of money spent on new capital assets in each period. You can also enter negative numbers to represent selling or disposing of assets.
Useful Life (Required): How long the asset is expected to last, It is measured in periods, not years, if you have a monthly period and a 5 years useful life, you should enter 5*12 = 60 here.
The function tracks each investment "vintage" separately. If you enter a $10k CapEx in Period 1 with a 5-period life, and a $20k CapEx in Period 2 with a 10-period life, the function remembers both groups and depreciates them on their own independent schedules before summing the totals.
Method (Optional): How you want to calculate the drop in value. Choose SL for Straight Line or DDB for Double Declining Balance (which results in a faster drop early on). If left blank, it defaults to SL.
Salvage (Optional): The estimated resale value of the asset at the end of its useful life. The depreciation will stop at this amount. Note that this is an absolute dollar amount, not a percentage. Defaults to 0.
Filter (Optional): A condition to pause new investments. If this is set to 0 (false) for a given period, any CapEx entered in that exact period is ignored. However, your older, existing assets will continue to depreciate normally.
Depreciating Historical Balance
Ideally, you should pull the depreciation schedule for historical balances from your accounting system, since those schedules are usually fixed.
If you do need to depreciate a historical balance (perhaps you don't have access to the data), you can create a new variable. Just use prev() or hardcode the balance into the timeperiod where you start depreciating it, leave the rest of the time periods blank or 0, and apply the depreciate() function to it.
Keep in mind that if you do it this way, you should use SL(Straight Line) because using DDB(Double Declining Balance) won't be mathematically accurate. DDB requires knowing the original useful life and exact how many periods have passed since the asset was acquired.
If you absolutely must use DDB to depreciate a historical balance, please let us know and we can add a specific function for that, but we generally try to keep our library as lean and focused as possible.