DB
使用固定余额递减法返回指定期间资产的折旧。
语法
DB(<cost>, <salvage>, <life>, <period>[, <month>])
parameters
术语 | 定义 |
---|---|
cost | 资产的原始成本。 |
salvage | 折旧结束时的价值(有时称为资产的残值)。 此值可以为 0。 |
变得生动鲜活 | 对资产进行折旧的周期数(有时称为资产的可用生命周期)。 |
period | 要计算其折旧的周期。 Period 必须使用与 life 相同的单位。 必须介于 1 至 life 之间(含首尾)。 |
月份 | (可选)第一年的月数。 如果省略 month,则假定为 12。 |
返回值
指定期间内的折旧。
备注
固定余额递减法以固定比率计算折旧。 DB 使用以下公式来计算周期的折旧:
$$(\text{ cost } - \text{ total depreciation from prior periods }) \times \text{ rate }$$
其中:
- $\text{ rate } = 1 - ((\frac{ \text{ salvage } }{ \text{ cost } })^{ (\frac{ 1 }{ \text{ life } }) })\text{ , rounded to three decimal places }$
首个及最后一个期间的折旧为特殊情况。
对于首个周期,DB 使用以下公式:
$$\frac{ \text{ cost } \times \text{ rate } \times \text{ month } }{ 12 }$$
对于最后一个周期,DB 使用以下公式:
$$\frac{ (\text{ cost } - \text{ total depreciation from prior periods }) \times \text{ rate } \times (12 - \text{ month }) }{ 12 }$$
period 和 month 舍入为最接近的整数。
如果出现以下情况,则返回错误:
- cost < 0。
- salvage < 0。
- life < 1。
- period < 1 或 period > life。
- month < 1 或 month > 12。
在已计算的列或行级安全性 (RLS) 规则中使用时,不支持在 DirectQuery 模式下使用此函数。
示例
示例 1
以下 DAX 查询:
EVALUATE{ DB(1000000, 0, 6, 1, 2) }
返回第一年最后两个月的资产折旧,假设资产在 6 年后价值 \$0。
[值] |
---|
166666.666666667 |
示例 2
下面计算了所有资产在其生命周期中不同年份的总折旧。 在此处,第一年仅包含 7 个月的折旧,而最后一年仅包含 5 个月的折旧。
DEFINEVAR NumDepreciationPeriods = MAX(Asset[LifeTimeYears])+1VAR DepreciationPeriods = GENERATESERIES(1, NumDepreciationPeriods)EVALUATEADDCOLUMNS ( DepreciationPeriods, "Current Period Total Depreciation", SUMX ( FILTER ( Asset, [Value] <= [LifetimeYears]+1 ), DB([InitialCost], [SalvageValue], [LifetimeYears], [Value], 7) ))