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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors