# NPV - script function

NPV() returns the aggregated net present value of an investment based on a constant discount\_rate per period and a series of future payments (negative values) and incomes (positive values), represented by the numbers in value, iterated over a number of records, as defined by a group by clause. The payments and incomes are assumed to occur at the end of each period.

Syntax:

NPV(discount\_rate, value)

Return data type: numeric. The result has a default number format of money.

Arguments:

* discount\_rate: discount\_rate is the rate of discount over the length of the period. discount\_rate is a constant.
* value: The expression or field containing the data to be measured.

Limitations:

Text values, NULL values and missing values are disregarded.

Examples and results:

Add the example script to your document and run it. Then add, at least, the fields listed in the results column to a sheet in your document to see the result.

`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;`

Example results

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

Given that the Cashflow table is loaded as in the previous example:

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

Example results

| Year | Discount | NPV2\_2013 |
| --- | --- | --- |
| 2013 | 0.1 | -$3456.05 |
| 2013 | 0.2 | $5666.67 |

| Example | Result field | Result value |
| --- | --- | --- |
| `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 |
| Given that the Cashflow table is loaded as in the previous example:`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> |  |