# NPV - 脚本函数

NPV() 用于根据迭代于 group by 子句定义的大量记录上的 value 的数值表示的一系列未来付款（负值）和收入（正值）以及每周期的常量 discount\_rate，返回投资聚合净现值。假设为在每个周期结束时发生的付款和收入。

语法：

NPV(discount\_rate, value)

返回数据类型： 数字。 结果默认采用货币数字格式。

参数：

* discount\_rate:discount\_rate 是在整个期间的折扣率。 discount\_rate 是一个常数。
* value: 表达式或字段包含要度量的数据。

限制：

文本值，NULL 值和缺失值都忽略不计。

示例和结果：

将示例脚本添加到文档并运行。然后，至少要将结果列中列出的字段添加到文档中的表格才能查看结果。

`Cashflow:` `LOAD 2013 as Year, * inline [` `Date|Discount|Payments` `2013-01-01|0.1|-10000` `2013-03-01|0.1|3000` `2013-10-30|0.1|4200` `2014-02-01|0.2|6800` `] (delimiter is '|');` ` ` `Cashflow1:`

`LOAD Year,NPV(0.2, Payments) as NPV1_2013  Resident Cashflow Group By Year;`

示例结果

| 年 | NPV1\_2013 |
| --- | --- |
| 2013 | -$540.12 |

前提是 Cashflow 表格像之前的示例一样加载：

`LOAD Year,NPV(Discount, Payments) as NPV2_2013  Resident Cashflow Group By Year, Discount;`

示例结果

| 年 | 折扣 | NPV2\_2013 |
| --- | --- | --- |
| 2013 | 0.1 | -$3456.05 |
| 2013 | 0.2 | $5666.67 |

| 示例 | 结果字段 | 结果值 |
| --- | --- | --- |
| `Cashflow:`<br>`LOAD 2013 as Year, * inline [`<br>`Date\|Discount\|Payments`<br>`2013-01-01\|0.1\|-10000`<br>`2013-03-01\|0.1\|3000`<br>`2013-10-30\|0.1\|4200`<br>`2014-02-01\|0.2\|6800`<br>`] (delimiter is '\|');`<br>` `<br>`Cashflow1:`<br>`LOAD Year,NPV(0.2, Payments) as NPV1_2013  Resident Cashflow Group By Year;` | Year<br><br>2013 | NPV1\_2013<br><br>-$540.12 |
| 前提是 Cashflow 表格像之前的示例一样加载：`LOAD Year,NPV(Discount, Payments) as NPV2_2013  Resident Cashflow Group By Year, Discount;` | <table> <colgroup><col> <col> <col> </colgroup> <tr> <td> <p>Year</p> <p>2013<br>2013</p> </td> <td> <p>Discount</p> <p>0.1<br>0.2</p> </td> <td> <span>NPV2_2013</span> <p> <br>-$3456.05<br>$5666.67</p> </td> </tr>  </table> |  |