Forum Discussion

mrothschild's avatar
mrothschild
Continued Contributor
7 years ago
Solved

loan amortization?

This seems like it should be much easier than I've found it to be. I have a table that has Columns A, B, and D below and I'm trying to calculate C & E.     C = prior row's E and E = current row C ...
  • mrothschild's avatar
    mrothschild
    7 years ago

    Wow, well that was way more difficult than it should be for such a simple financial concept, but given my search of the forums, this is a significant shortfall in BI. 

     

    The link here: https://www.dropbox.com/s/hryw5ezenojphzn/LoanAmortization.pbix?dl=0

     

    has the PBIX file that does the job (though for those more sophisticated, it uses straight line debt amortization rather than PMT amortization).

     

    The process, as I suspected, uses the workaround of calculating a running total cumulative amortization.  That DAX is as follows:

    Cumulative Amortization = 
    CALCULATE(
            SUM(LoanAmortization[Amortization]),
            FILTER(ALL(LoanAmortization),LoanAmortization[Period]<=EARLIER(LoanAmortization[Period])),
            FILTER(ALL(LoanAmortization),LoanAmortization[Loan ID]=EARLIER(LoanAmortization[Loan ID])
    
    ))

    One also has to calculate the lagged cumulative amortization, which looks like above, but replaces " <= " with just " < ". as shown: 

    Cumulative Amortization (lagged) = 
    CALCULATE(
            SUM(LoanAmortization[Amortization]),
            FILTER(ALL(LoanAmortization),LoanAmortization[Period]<EARLIER(LoanAmortization[Period])),
            FILTER(ALL(LoanAmortization),LoanAmortization[Loan ID]=EARLIER(LoanAmortization[Loan ID])
    
    ))

    Once those are calculated, and one has the Starting Loan Amount (which I created by using a related table, called "Starting Loan Amount"), then the Beginning Debt (calculated) is as follows: 

    Beginning Debt (calculated) = 
        LoanAmortization[Starting Loan Amount] + LoanAmortization[Cumulative Amortization (lagged)]

     

    and the Ending Debt (calculated) is as follows:

     

    Ending Debt (calculated) = 
        LoanAmortization[Starting Loan Amount] + LoanAmortization[Cumulative Amortization]

    I'm still working through the last period amortization to avoid circular references, but I'm less concerend about that.

     

    Hopefully this helps for all those who were looking for a solution.

     

     

    Here's how the data looks for comparisons (there's some rounding that leads to imprecise comparisons as I moved from Excel to PBIX and back again, but the process works):

     

    Loan IDPeriodStarting Loan AmountBeginning DebtAmortizationEnding DebtCumulative AmortizationCumulative Amortization (lagged)Beginning Debt (calculated)Ending Debt (calculated)
    X0$9,450$9,450 $9,450  $9,450$9,450
    X1$9,450$9,450($53)$9,397($53) $9,450$9,397
    X2$9,450$9,398($53)$9,345($106)($53)$9,397$9,344
    X3$9,450$9,345($53)$9,292($159)($106)$9,344$9,291
    X4$9,450$9,293($53)$9,240($212)($159)$9,291$9,238
    X5$9,450$9,240($53)$9,187($265)($212)$9,238$9,185
    X6$9,450$9,188($53)$9,135($318)($265)$9,185$9,132
    X7$9,450$9,135($53)$9,082($371)($318)$9,132$9,079
    X8$9,450$9,083($53)$9,030($424)($371)$9,079$9,026
    X9$9,450$9,030($9,030)$0($9,454)($424)$9,026($4)
    Y0$7,500$7,500 $7,500  $7,500$7,500
    Y1$7,500$7,500($45)$7,455($45) $7,500$7,455
    Y2$7,500$7,455($45)$7,410($90)($45)$7,455$7,410
    Y3$7,500$7,410($45)$7,365($135)($90)$7,410$7,365
    Y4$7,500$7,365($45)$7,320($180)($135)$7,365$7,320
    Y5$7,500$7,320($45)$7,275($225)($180)$7,320$7,275
    Y6$7,500$7,275($7,275)$0($7,500)($225)$7,275$0