The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
@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 Method | Date of Payment |
111000111 | Cash | 23/01/2023 |
111000111 | Cash | 24/01/2023 |
111000111 | Cash | 25/01/2023 |
111000111 | Cheque | 26/01/2023 |
111000111 | Credit Card | 27/01/2023 |
111000111 | Direct Credit | 28/01/2023 |
111000111 | Cash | 29/01/2023 |
Solved! Go to 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:
Hey Dear,
You can try this code!
@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 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.
hi @EMUDATA
try to plot any visual with Account ID column and a measure like:
Measure = MAX(TableName[Date of Payment])
User | Count |
---|---|
26 | |
10 | |
8 | |
6 | |
6 |
User | Count |
---|---|
31 | |
11 | |
10 | |
10 | |
9 |