Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
DataNinja777
Super User
Super User

Creating amortization schedule for prepayments, accrual and deferred revenue

Hi Power BI Community,

I am trying to create amortization schedule for service table like below:

DataNinja777_0-1711167535682.png

In order to do that disconnected tables were set up in the data model.  

 

DataNinja777_1-1711167584057.png

 

Amortization:=SUMX (
    Service,
    IF (
        Service[Start date] <= MAX ( 'Calendar_445'[Date] )
            && Service[End date] >= MAX ( 'Calendar_445'[Date] ),
        Service[Daily amort]
            * ( MAX ( 'Calendar_445'[Date] ) - Service[Start date] ),
        BLANK ()
    )
)

DataNinja777_2-1711167779288.png

 

The formula above produced the colored conditionally formatted result to accumulate the expenses or revenues throughout the service performance period.  I'd like to write the formula to calculate the P&L charge for the respective months, which respects the time dimension and add up correctly by day granurality in the calendar table, but due to the lack of relationship between the calendar table and the service table which contain two date field, I found it difficult to write the formula to add up the daily amount cumulating over time in the calendar table.  

I'd appreciate it if anyone could write the formula to show the max month - previous max month of the outputs shown in the conditional formatting above.  

 

PL charge :=
VAR PreviousMonthAmortization =
    CALCULATE (
        [Amortization],
        ALL ( Calendar_445 ),
        KEEPFILTERS ( 'Calendar_445'[Fiscal Month Number] - 1 )
    )
RETURN
    [Amortization] - PreviousMonthAmortization

I've written the formula above, but it is not producing the intended output and just producing the same output as the visual above.  

Thank you for your help.  



1 ACCEPTED SOLUTION

This issue was resolved by utilizing the dax formula provided in the sqlbi dax pattern training course.  

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Based on data shared in the first image, show the expected result very clearly.  Also, share data in a format that can be pasted in an Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks @Ashish_Mathur 

Please find attached the table in copy and pastable format.  

 

CustomerStart dateEnd dateAmountPeriodDaily amort
Customer 101/01/2212/31/2310000007291371.742112
Customer 203/01/2202/28/2713000001825712.3287671
Customer 305/01/2404/30/2814300001460979.4520548
Customer 407/03/2106/30/238900007271224.209078
Customer 508/25/2207/31/2711570001801642.4208773
Customer 603/05/2102/28/2512727001456874.1071429
Customer 703/08/2402/28/2616545107222291.565097
Customer 811/02/2110/31/26215086318241179.201206

Expected output is shown in column D and the formulatext for that is shown in column D.  

DataNinja777_0-1711176109073.png

Thanks a lot for your help.  

I am not sure how much i can help but i can try.  Share the download link of the Excel file with your Pivot Tables and formulas intact.  i will try to translate those formulas in the DAX formula language.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks a lot @Ashish_Mathur , but unfortunately, I cannot share the link.  

PL charge :=
VAR PreviousMonthAmortization =
    MAX ( 'Calendar_445'[Fiscal Year Month Number] ) - 1
RETURN
    [Amortization]
        - CALCULATE (
            [Amortization],
            KEEPFILTERS ( 'Calendar_445'[Fiscal Year Month Number] ) = PreviousMonthAmortization
        )

I'd greatly appreciate it if you could fix the formula above 

"Semantic Error: KEEPFILTERS function can only be used as a top level filter argment of CALCULATE and CALCULATETABLE or with a table argument of a function performing a table scan."  I am not sure how I can debug the error in the formula.  

DataNinja777_0-1711178119657.png

 

 

This issue was resolved by utilizing the dax formula provided in the sqlbi dax pattern training course.  

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.