Returns the present value of a loan or an investment, based on a constant interest rate. Optional future value and type of payment can be used.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let func = | |
(Rate as number, Nper as number, Pmt as number, optional Fv_ as number, optional Type_ as number) => | |
let | |
// Source for calculation logic: https://community.powerbi.com/t5/Community-Blog/P-Q-Excel-to-DAX-Translation/ba-p/1061107 | |
Type = if Type_ is null then 0 else Type_, | |
Fv = if Fv_ = null then 0 else Fv_, | |
Custom3 = | |
if Rate = 0 | |
then -1 * ( (Pmt * Nper) + Fv) | |
else ( Pmt * ( 1 + Rate * Type) * | |
(( Number.Power(1 + Rate, Nper) -1 )/ Rate ) + Fv ) | |
/ Number.Power(1 + Rate , Nper) * -1 | |
in | |
Custom3 , | |
documentation = [ | |
Documentation.Name = " Xls.PV ", | |
Documentation.Description = " Returns the present value of a loan or an investment, based on a constant interest rate. ", | |
Documentation.LongDescription = " Returns the present value of a loan or an investment, based on a constant interest rate. Optional future value and type of payment can be used. ", | |
Documentation.Category = " Xls.Financial ", | |
Documentation.Source = " www.TheBIcountant.com . ", | |
Documentation.Version = " 1.0 ", | |
Documentation.Author = " Imke Feldmann ", | |
Documentation.Examples = {[Description = " ", | |
Code = " let | |
Rate = 0.08, | |
Nper = 20 , | |
Pmt = 500, | |
Fv_ = 10000, | |
Type_ = 1, | |
FunctionCall = fnPV(Rate, Nper, Pmt, Fv_, Type_) | |
in | |
FunctionCall ", | |
Result = " -7447,28167406318 | |
"]}] | |
in | |
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment