Most Recent Receive Date for same Record

kjacob318

New Member
Joined
Dec 22, 2015
Messages
13
Hello,

I am trying to create a calculated field in my query to display the most recent receive date (other than the current OrderID) for a material and serial. Below is my table1 example:

[TABLE="width: 644"]
<tbody>[TR]
[TD]ORDERID[/TD]
[TD]MATERIAL[/TD]
[TD]SERIAL NUMBER[/TD]
[TD]CREATE DATE[/TD]
[TD]RECEIVE DATE[/TD]
[/TR]
[TR]
[TD]A5[/TD]
[TD]C123[/TD]
[TD]412[/TD]
[TD]1/1/2017[/TD]
[TD]3/3/2017[/TD]
[/TR]
[TR]
[TD]A4[/TD]
[TD]XYZF4[/TD]
[TD]128[/TD]
[TD]12/20/2016[/TD]
[TD]12/28/2016[/TD]
[/TR]
[TR]
[TD]A3[/TD]
[TD]C123[/TD]
[TD]412[/TD]
[TD]10/12/2016[/TD]
[TD]10/30/2016[/TD]
[/TR]
[TR]
[TD]A2[/TD]
[TD]ABYD3[/TD]
[TD]325[/TD]
[TD]9/10/2016[/TD]
[TD]9/25/2016[/TD]
[/TR]
[TR]
[TD]A1[/TD]
[TD]XYZF4[/TD]
[TD]128[/TD]
[TD]8/12/2016[/TD]
[TD]9/1/2016[/TD]
[/TR]
</tbody><colgroup><col><col><col><col span="2"></colgroup>[/TABLE]


What I want my result to be is:
[TABLE="width: 798"]
<tbody>[TR]
[TD]ORDERID[/TD]
[TD]MATERIAL[/TD]
[TD]SERIAL NUMBER[/TD]
[TD]CREATE DATE[/TD]
[TD]RECEIVE DATE[/TD]
[TD]MAX RECEIVE DATE[/TD]
[/TR]
[TR]
[TD]A5[/TD]
[TD]C123[/TD]
[TD]412[/TD]
[TD]1/1/2017[/TD]
[TD]3/3/2017[/TD]
[TD]10/30/2016[/TD]
[/TR]
[TR]
[TD]A4[/TD]
[TD]XYZF4[/TD]
[TD]128[/TD]
[TD]12/20/2016[/TD]
[TD]12/28/2016[/TD]
[TD]9/1/2016[/TD]
[/TR]
[TR]
[TD]A3[/TD]
[TD]C123[/TD]
[TD]412[/TD]
[TD]10/12/2016[/TD]
[TD]10/30/2016[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A2[/TD]
[TD]ABYD3[/TD]
[TD]325[/TD]
[TD]9/10/2016[/TD]
[TD]9/25/2016[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]A1[/TD]
[TD]XYZF4[/TD]
[TD]128[/TD]
[TD]8/12/2016[/TD]
[TD]9/1/2016[/TD]
[TD][/TD]
[/TR]
</tbody><colgroup><col><col><col><col span="2"><col></colgroup>[/TABLE]


I am trying to do DMAX in my criteria for my query but it's not working. It's prompting me to type in "RECEIVE DATE" & "CREATE DATE".

Code:
DMax("[RECEIVE DATE]","TABLE1","[SERIAL NUMBER] = [SERIAL NUMBER] And [RECEIVE DATE] < #" & [CREATE DATE] & "#")
Code:
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
You cannot put the column names inside the quotes, or they become literal text. You want to create a string that includes the actual serial number. Assuming serial numbers are numeric.

DMax("[RECEIVE DATE]","TABLE1","[SERIAL NUMBER] = " & [SERIAL NUMBER] & " And [RECEIVE DATE] < #" & [CREATE DATE] & "#")
or
DMax("[RECEIVE DATE]","TABLE1","[SERIAL NUMBER] = " & [SERIAL NUMBER] & " AND [MATERIAL] = '" & [MATERIAL] & "'" & " And [RECEIVE DATE] < #" & [CREATE DATE] & "#")

Seems like you know this since you did it right for the date, just missed it for the serial number.
 
Upvote 0
Awesome! Thank you! My Serial Numbers may not always be numerical but I included the "'" to mimic the Material and it worked perfectly!

I appreciate the help!
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top