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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
deng2431
Helper I
Helper I

DAX - help with last date based on multiple distinct keys

Hi PowerBi community,

 

I am new to Powerbi and DAX, I am trying to solve an issue of selecting the MAX/Last date from a column (payment date) where there were multiple same numbers (Invoice Key column). if there is no multiple keys then just display the 1 payment date. i get the concept of what needs to be done but i just cant get my head wrapped around how to partition the distinct invoice keys and then use that to find the max/last date from that partition. any help or advice is really appreciated. thank you!!

 

a4f207c1-230e-457d-9113-36c336a27f95.png

 

1 ACCEPTED SOLUTION
deng2431
Helper I
Helper I

Hi Magnus,

 

Thank you for your response, i just so happen to came across a solution to my issues earlier using the below query:

 

Payment date (Final) = calculate(max(Payments[Payment date]),  allexcept(Payments, 'Payments[Invoice_key]))
 
which works exactly what i wanted, i have tried your solution as well but it doesnt take into consideration of finding the max date in the same set of Invoice keys.
 
thank for your time with this 🙂

View solution in original post

2 REPLIES 2
deng2431
Helper I
Helper I

Hi Magnus,

 

Thank you for your response, i just so happen to came across a solution to my issues earlier using the below query:

 

Payment date (Final) = calculate(max(Payments[Payment date]),  allexcept(Payments, 'Payments[Invoice_key]))
 
which works exactly what i wanted, i have tried your solution as well but it doesnt take into consideration of finding the max date in the same set of Invoice keys.
 
thank for your time with this 🙂
Anonymous
Not applicable

You can create the following new measure and add it to your visual.

Latest payment =
CALCULATE(
    MAX(Payments[Payment date]),
    REMOVEFILTERS(Payments[Payment date])
)
 
The filter condition will allow finding the maximum payment date but keeping the Invoice_key to be the same.
 
Br,
Magnus

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.