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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
EMUDATA
Regular Visitor

Help with DAX code to group a column by an account ID and look for last payment date

@Community Members.

I need help in writing the appropriate DAX code that looks for the last payment date of each account in a dataset.

The code must group the Account ID column by Account IDs and look for the lastest date in Date of Payment column.

Account ID Payment MethodDate of Payment 
111000111Cash23/01/2023
111000111Cash24/01/2023
111000111Cash25/01/2023
111000111Cheque26/01/2023
111000111Credit Card27/01/2023
111000111Direct Credit 28/01/2023
111000111Cash29/01/2023
1 ACCEPTED SOLUTION

hi @EMUDATA 

then try to add a calculated column like:

column = 
VAR _lastdate=
MAXX(
    FILTER(
        data,
        data[Account ID]=EARLIER(data[Account ID])
    ),
    data[Date of Payment]
)
RETURN
IF(
    [Date of Payment]=_lastdate,
    1,0
)

it worked like:

FreemanZ_0-1682693467167.png

View solution in original post

6 REPLIES 6
Ajendra
Resolver I
Resolver I

Hey Dear,

 

You can try this code!

 

Output_Table = SUMMARIZE(FactTable,FactTable[ID],FactTable[Payment Mode],"Latest Date",
CALCULATE(MAX(FactTable[Payment Date]),FILTER(FactTable,FactTable[Payment Mode]=MAX(FactTable[Payment Mode]))))
 
Thanks,
Ajendra
EMUDATA
Regular Visitor

@FreemanZ something life IF(lastdate),1,0. But I am missing how to do this for each account id

hi @EMUDATA 

then try to add a calculated column like:

column = 
VAR _lastdate=
MAXX(
    FILTER(
        data,
        data[Account ID]=EARLIER(data[Account ID])
    ),
    data[Date of Payment]
)
RETURN
IF(
    [Date of Payment]=_lastdate,
    1,0
)

it worked like:

FreemanZ_0-1682693467167.png

@FreemanZ  You are very talented 🤔

EMUDATA
Regular Visitor

@FreemanZ thank you but I need to create a conditional column that indicates the last payment so I can filter data on last payment record for each account.

FreemanZ
Super User
Super User

hi @EMUDATA 

try to plot any visual with Account ID column and a measure like:
Measure = MAX(TableName[Date of Payment])

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.