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
ayana
Frequent Visitor

Calculated column to apply values from a different column

I'm working with debt collection data and I have a problem I hope someone can help resolve. Scenario: When there are several missed payments and a collection is made, it is applied to the oldest missed payment(s). For instance, if there are missed payments in Jan, Feb, Mar and April, ($500 each month, cumulative $2000) and a payment is made in April (e.g.$1000), that payment is applied to Jan ($500) and Feb ($500). If the total missedpayment is made ($2000), it is applied to Jan, Feb, March and April and the account becomes current. The challenge is that the source data does not have this information and I would like to create a DAX command to that applies the collected amount to the oldest missedpayments. Does anyone know if this is possible and if so, how? A sample table showing the expected results is included. For this, I'm only working with a fact table and a date table.

Thanks in advance for your insights!

CreditedPaymentsSample.png

 

1 ACCEPTED SOLUTION
v-xianjtan-msft
Community Support
Community Support

Hi @ayana 

 

Please try creating “CreditedAmount” column with the following DAX:

CreditAmount = 
VAR CurrentMissedPaymentID = 'DataTable'[MissedPaymentID]

VAR CumulativeCollectedAmount =
CALCULATE(
    SUM('DataTable'[CollectedAmount]),
    FILTER(
        ALL('DataTable'),
        'DataTable'[Month] <= EARLIER('DataTable'[Month])
    )
)

VAR PreviousCumulativeMissedPmts =
CALCULATE(
    MAX('DataTable'[CumulativeMissedPmts]),
    FILTER(
        'DataTable',
        'DataTable'[MissedPaymentID] = CurrentMissedPaymentID - 1
    )
)

RETURN
IF(
    CumulativeCollectedAmount - 'DataTable'[CumulativeMissedPmts] >= 0,
    'DataTable'[MsdPmtAmount],
    MAX(0, CumulativeCollectedAmount - PreviousCumulativeMissedPmts)
)

 

Here is my test result, i hope this can meet your requirement.

vxianjtanmsft_0-1724808640923.png

 

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-xianjtan-msft
Community Support
Community Support

Hi @ayana 

 

Please try creating “CreditedAmount” column with the following DAX:

CreditAmount = 
VAR CurrentMissedPaymentID = 'DataTable'[MissedPaymentID]

VAR CumulativeCollectedAmount =
CALCULATE(
    SUM('DataTable'[CollectedAmount]),
    FILTER(
        ALL('DataTable'),
        'DataTable'[Month] <= EARLIER('DataTable'[Month])
    )
)

VAR PreviousCumulativeMissedPmts =
CALCULATE(
    MAX('DataTable'[CumulativeMissedPmts]),
    FILTER(
        'DataTable',
        'DataTable'[MissedPaymentID] = CurrentMissedPaymentID - 1
    )
)

RETURN
IF(
    CumulativeCollectedAmount - 'DataTable'[CumulativeMissedPmts] >= 0,
    'DataTable'[MsdPmtAmount],
    MAX(0, CumulativeCollectedAmount - PreviousCumulativeMissedPmts)
)

 

Here is my test result, i hope this can meet your requirement.

vxianjtanmsft_0-1724808640923.png

 

Best Regards,
Jarvis Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

lbendlin
Super User
Super User

which business question are you trying to answer with this?

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.