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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
PAPalmer
Frequent Visitor

DAX create a column for max date by Order Id

Hello, 

I am trying to get the Max date for the order id . Here is what I have as my table:

Order Id Date Status
1733/14/2022Submitted
1733/19/2022Level 2
1733/20/2022Level 3
1733/22/2022Level 4
1733/25/2022Level 5
5496/27/2022Submitted
549 Level 2
5497/06/2022Level 3
54907/06/2022Level 4
54907/08/2022Level 5

There are some Status which may not have a date. The desired output is to have a separate column to display the max date for each order id , which should be the Level 5 dates.
I have tried the below two approaches.

 

Latest Dt = CALCULATE(MAX('Orders'[Date]),ALLEXCEPT('Orders','Orders[Order Id]))
Latest Dt = CALCULATE(MAX('Orders'[Date]),
                      FILTER('Orders','Orders[Order Id]=EARLIER('Orders'[Order Id]))

 

 Both these are displaying the date for the Submitted status, which is the minimum date. 

 

Any help will be appreciated. 

 

Thank you,

Petra

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @PAPalmer 

 

Plesse try the following dax:

Measure = 
VAR _max_date = MAX('Table'[ Date ])
RETURN CALCULATE(MAX('Table'[Status]),FILTER('Table','Table'[ Date ] = _max_date))

 

This is the result you want:

vjialongymsft_0-1713230221702.png

 

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @PAPalmer 

 

Plesse try the following dax:

Measure = 
VAR _max_date = MAX('Table'[ Date ])
RETURN CALCULATE(MAX('Table'[Status]),FILTER('Table','Table'[ Date ] = _max_date))

 

This is the result you want:

vjialongymsft_0-1713230221702.png

 

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi  v-jialongy-msft

Thank you so much, it works well where all the dates are in the same year. 
For dates that  shift to another year  eg : 

Order Id Date Status 
45711/2/2022Submitted
45712/1/2022Level 1
45712/15/2022Level 2
45712/22/2022Level 3
45712/30/2022Level 4
4571/10/2023Level 5

It is picking the min value , which is 11/2/2022. Could you please help me with it . Appreciate your help

Thank you,

Petra.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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