CALC.xnpv(rate, values, dates)
Returns the net present value for a schedule of cash flows that is not necessarily periodic, based on a 365-day year. This CALC function returns the same result as the Excel function of the similar name.
Parameters
- rate
-
Discount rate to apply to the cash flows
- values
-
Array of numbers representing a series of payments (negative values) and income (positive values) occurring at the specified dates. Must contain at least one positive value and one negative value. Typically, for an investment, the first value is the (negative) amount of the investment, and subsequent values are (positive) payments.
- dates
-
Array of dates on which payments are made (first value must be the earliest date). The array can list the dates in any order so long as the first item is the earliest date in the series.
Example
Net present value for a $10,000 investment made on January 1, 2008 at a 9% interest rate, where the following subsequent payment are made:
-
$2,750 on March 1, 2008
-
$4,250 on October 30, 2008
-
$3,250 on February 15, 2009
-
$2,750 on April 1, 2009
var date1 = new Date(2008, 0, 1);
var date2 = new Date(2008, 2, 1);
var date3 = new Date(2008, 9, 30);
var date4 = new Date(2009, 1, 15);
var date5 = new Date(2009, 3, 1);
CALC.xnpv(0.09, [-10000, 2750, 4250, 3250, 2750],[date1, date2, date3, date4, date5]);
// returns 2086.647602031535 (approx $2,086.65)
To reference data when scripting a Data Worksheet Expression Column or Dashboard Calculated Field, use the field syntax. Example:
CALC.xnpv(0.09, [field['Cost'], field['Payment1'], field['Payment2'], field['Payment3'], field['Payment4']],[field['InvestDate'], field['PayDate1'], field['PayDate2'], field['PayDate3'], field['PayDate4']])
To reference data in Dashboard global script, component script, or property script, use keywords such as value, selectedObjects, data, table, or parameter. Example:
CALC.xnpv(0.09, [parameter.Cost, parameter.Payment1, parameter.Payment2, parameter.Payment3, parameter.Payment4],[parameter.InvestDate, parameter.PayDate1, parameter.PayDate2, parameter.PayDate3, parameter.PayDate4])
How to access data in Data Worksheet Expression Columns…To create an expression column in a Data Worksheet, press the ‘Create Expression’ button . (See Create a New Data Field for more details.)
Insert fields (and parameters) into the script by clicking the items in the tree. Example syntax:
To reference the data contained in other cells of the data block, see the topics below: Example 1. Cell Referencing
This example illustrates how you can reference the cells of another data block from within an Expression Column. You will use the tables in the folder of the ‘Orders’ data source to create a data block that has columns for product ID, product name, category ID, and category name.
Let’s say that you want to add a column to the ‘PRODUCTS1’ data block that will contain the category name corresponding to each entry in the ‘CAT_ID’ column. The best way to do this is to join the data blocks together (see Join Data), but to practice using cell references, in this case you will create this new column as an expression column. Follow the steps below:
How to access data in Dashboard Calculated Fields…To create a calculated field in a dashboard, right-click on the data block, data model, or query to which you want to add the calculated field, and select ‘New Calculated Field’. (See Create a New Data Field for more details.)
Insert fields (and parameters and component properties) into the script by clicking the items in the tree. Example syntax:
How to access data in Dashboard Property Expressions…To set a Dashboard property value using an expression, press the ‘Value Type’ button and select the ‘Expression’ option to open the Formula Editor. (See Dynamically Set Properties for more details.)
To insert a reference a component’s data, use the value, selectedObjects, data, or table property of the component. Example syntax:
See Dashboard Object Reference for information about accessing dashboard settings and data in script.
How to access data in Dashboard Scripts…To add script to a Dashboard component, right-click the desired component, and select ‘Properties’ from the context menu to open the ‘Properties’ panel. Note: You can also access menu options from the ‘More’ button () in the mini-toolbar. Select the Script tab to open the Script Editor, and select either Script or onClick. See Add Component Script for more information about these options.
To add global script to a Dashboard, press ‘Options’ button in the toolbar to open the ‘Dashboard Options’ panel. Select the Script tab to open the Script Editor, and select either onInit or onRefresh. See Add Dashboard Script for more information about these options.
To insert a reference a component’s data, use the value, selectedObjects, data, or table property of the component. Example syntax:
See Dashboard Object Reference for information about accessing dashboard settings and data in script. |













