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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
ngocrin1
Frequent Visitor

Get the value base on lastest date condition

Hi Everyone,

I have order table and delivery table and need to get the exact value (Delivery date & Order ID) as below:

ngocrin1_0-1687181867543.png

I dont know the way to solve it in Power Query. Has everyone help me?

1 ACCEPTED SOLUTION

Hi @ngocrin1 

 

Do you have an OrderID column in Delivery table? If so, you can use Merge queries feature. Select both OrderID and CustomerKey as matching columns. This will match the corresponding DeliveryDate based on OrderID and CustomerKey fast and easily. 

 

If you don't have OrderID column in Delivery table, you can still use Merge queries feature but select only CustomerKey as matching column. 

vjingzhang_0-1687337614416.png

Then add a custom column with below code 

let vOrderDate = [OrderDate] in List.Min(Table.SelectRows([Delivery Table], each [DeliveryDate] >= vOrderDate)[DeliveryDate])

vjingzhang_1-1687337725357.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

4 REPLIES 4
Syk
Super User
Super User

You will need the orderID in your delivery table as well.. Otherwise there's no way to tell which order the delivery date is referencing.

ngocrin1
Frequent Visitor

Tks @Syk . I think if we can add a column with the date range between the day of 2 orders we can lookup exactly the order. But I dont know to do it.

ngocrin1_0-1687184448884.png

 

Hi @ngocrin1 

 

Do you have an OrderID column in Delivery table? If so, you can use Merge queries feature. Select both OrderID and CustomerKey as matching columns. This will match the corresponding DeliveryDate based on OrderID and CustomerKey fast and easily. 

 

If you don't have OrderID column in Delivery table, you can still use Merge queries feature but select only CustomerKey as matching column. 

vjingzhang_0-1687337614416.png

Then add a custom column with below code 

let vOrderDate = [OrderDate] in List.Min(Table.SelectRows([Delivery Table], each [DeliveryDate] >= vOrderDate)[DeliveryDate])

vjingzhang_1-1687337725357.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Tks. Excellent solution. I don't have OrderID so the "Add columns" step is exactly what I need.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors