# 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> |  |