# RangeXNPV - script function

RangeXNPV() returns the net present value for a schedule of cash flows that is not necessarily periodic. The result has a default number format of money. To calculate the net present value for a series of periodic cash flows, use the RangeNPV function.

Syntax:

RangeXNPV(discount\_rate, values, dates[, Expression])

Return data type: numeric

Arguments:

* dates: A payment date or a schedule of payment dates that corresponds to the cash flow payments.
* discount\_rate: The interest rate per period.
* values: A cash flow or a series of cash flows that corresponds to a schedule of payments in dates. Each value may be a single value or a range of values as returned by an inter-record function with a third optional parameter. The series of values must contain at least one positive and one negative value.

Limitations:

Text values, NULL values and missing values are disregarded.

All payments are discounted based on a 365-day year.

Example 1:

`RangeXNPV(0.1, -2500,'2008-01-01',2750,'2008-09-01')` returns 80.25.

Example 2:

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.

`RangeTab3:` `LOAD *,` ` recno() as RangeID,  ` `RangeXNPV(Field1,Field2,Field3) as RangeNPV;` `LOAD * INLINE [` `Field1|Field2|Field3` `10|5|-6000` `2|NULL|7000` `8|'abc'|8000` `18|11|9000` `5|5|9000` `9|4|2000`

`] (delimiter is '|');`

The resulting table shows the returned values of RangeXNPV for each of the records in the table:

Example results

| RangeID | RangeXNPV |
| --- | --- |
| 1 | $-49.13 |
| 2 | $777.78 |
| 3 | $98.77 |
| 4 | $25.51 |
| 5 | $250.83 |
| 6 | $20.40 |