XNPVT
Updated: 13 March 2015
Use the aggregate function XNPVT to calculate the net present value for a series of cash flows with irregular time periods—cash flows of varying amount occurring at various points in time. The net present value is calculated as:
Where
N

=

the number of cash flows

c_{i}

=

cash flow amount

t_{i}

=

time

r

=

1 + discount rate

Syntax
SELECT [wct].[XNPVT](
<@Disc_rate, float,>
,<@CF_Amt, float,>
,<@Time, float,>
Arguments
@Disc_rate
the rate to be used in the calculation. @Disc_rate is an expression of type float or of a type that can be implicitly converted to float.
@CF_Amt
the cash flow amounts to be used in the calculation. @CF_Amt is an expression of type float or of a type that can be implicitly converted to float.
@Time
the time (expressed in periods) associated with the @CF_Amt. @Time is an expression of type float or of a type that can be implicitly converted to float.
Return Type
float
Remarks
· @CF_Amt and @Time are passed in as pairs, but they can be passed into the function in any order.
· The @Disc_rate must remain constant for the GROUP of the aggregate.
· @Disc_rate should be in the same units as @Time.
Examples
In this example, we demonstrate the similarity between the XNPV function and the XNPVT function. This requires using the YEARFRAC function to calculate @Time setting the basis parameter = 3.
SELECT
wct.XNPV(.06,amt_cf,date_cf) AS XNPV
,wct.XNPVT(.06,amt_cf,wct.YEARFRAC('20111130',date_cf,3)) as XNPVT
FROM (VALUES
(100000,'20111130')
,(50000,'20120315')
,(2500,'20120718')
,(12500,'20121130')
,(37500,'20130123')
,(75000,'20130430')
,(90000,'20140206')
)n(amt_cf, date_cf)
This produces the following result.
In this example, we calculate the net present value using the actual/actual daycount convention rather than an actual/365 daycount convention.
SELECT
wct.XNPVT(.06,amt_cf,wct.YEARFRAC('20111130',date_cf,1)) as XNPVT
FROM (VALUES
(100000,'20111130')
,(50000,'20120315')
,(2500,'20120718')
,(12500,'20121130')
,(37500,'20130123')
,(75000,'20130430')
,(90000,'20140206')
)n(amt_cf, date_cf)
This produces the following result.
In this example, we calculate the net present value using NL/365 daycount convention, where leap years are counted as having 365 days.
SELECT
wct.XNPVT(.06,amt_cf,wct.DAYSNL('20111130',date_cf)/cast(365 as float)) as XNPVT
FROM (VALUES
(100000,'20111130')
,(50000,'20120315')
,(2500,'20120718')
,(12500,'20121130')
,(37500,'20130123')
,(75000,'20130430')
,(90000,'20140206')
)n(amt_cf, date_cf)
This produces the following result.
In this example we use the T360 function to calculate the net present value using a 30/360 daycount convention and assuming semiannual compounding.
SELECT
wct.XNPVT(SQRT(1.06)1,amt_cf,wct.T360('20140206','20111130',date_cf,2,0)) as XNPVT
FROM (VALUES
(100000,'20111130')
,(50000,'20120315')
,(2500,'20120718')
,(12500,'20121130')
,(37500,'20130123')
,(75000,'20130430')
,(90000,'20140206')
)n(amt_cf, date_cf)
This produces the following result.
Unlike the XNPV function where cash flows are discounted to the earliest date in the dataset, XNPVT supports discounting the cash flows to any arbitrary date, much like the XDCF function.
SELECT
wct.XNPVT(.06,amt_cf,wct.YEARFRAC('20110630',date_cf,3)) as XNPVT
,wct.XDCF(.06,'20110630',amt_cf,date_cf) as XDCF
FROM (VALUES
(100000,'20111130')
,(50000,'20120315')
,(2500,'20120718')
,(12500,'20121130')
,(37500,'20130123')
,(75000,'20130430')
,(90000,'20140206')
)n(amt_cf, date_cf)
This produces the following result.
See Also