XNPV - script function
XNPV() returns the aggregated net present value for a schedule of cashflows (not necessarily periodic) represented by paired numbers in pmt and date, iterated over a number of records as defined by a group by clause. Rate is the interest rate per period. All payments are discounted based on a 365-day year.
Syntax:
XNPV(discount_rate, pmt, date)
Return data type: numeric. The result has a default number format of money.
Arguments:
Argument | Description |
---|---|
discount_rate |
discount_rate is the rate of discount over the length of the period. |
value | The expression or field containing the data to be measured. |
date | The expression or field containing the schedule of dates corresponding to the cash flow payments given in pmt. |
Limitations:
Text values, NULL values and missing values in any or both pieces of a data-pair will result in the entire data-pair to be disregarded.
See also:
Examples:
Add the example script to your app and run it. To see the result, add the fields listed in the results column to a sheet in your app.
Example | Year | XNPV1_2013 |
---|---|---|
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,XNPV(0.2, Payments, Date) as XNPV1_2013 Resident Cashflow Group By Year; |
2013 |
$2104.37 |
Example | Year | Discount | XNPV2_2013 |
---|---|---|---|
Given that the Cashflow table is loaded as in the previous example: LOAD Year,XNPV(Discount, Payments, Date) as XNPV2_2013 Resident Cashflow Group By Year, Discount; Note that the Group By clause sorts the results by Year and Discount. The first argument, discount_rate, is given as a field (Discount), rather than a specific number, and therefore, a second sorting criterion is required. A field can contain a different values, so the aggregated records must be sorted to allow for different values of Year and Discount. |
2013 2013 |
0.1 0.2 |
-$3164.35 $6800.00 |