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