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
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 🙂
magsod
Solution Supplier
Solution Supplier

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
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.

Top Solution Authors