Add column with Max date from another table

jimrward

Well-known Member
Joined
Feb 24, 2003
Messages
1,877
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. Windows
I have a master table with 2 columns ID, Date, I also have another table called LastPM with a column called LastPM that contains a simple date in the form dd/mm/yyyy and it has 2 rows
10/9/2023
14/1/2024

I would like to create an additional column in my master table containing either the Max of table LastPM or to cut out some steps a conditional column
=if mastertable.Date > table.max(LastPM) then 1 else 0

I can’t seem to get the syntax correct, tried excel.currentworkbook(….

I can hardcode the row using {0} or {1} but I would like it to be a bit more flexible to choose Max so I can keep adding dates as and PM, preventative Maintenance is done
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
how about
=IF(B2>MAX($E$2:$E$3),1,0)

Book3
ABCDE
1IDDateLast PM
2A11/1/2409/10/23
3A21/2/2401/14/24
4A31/3/240
5A41/4/240
6A51/5/240
7A61/6/240
8A71/7/240
9A81/8/240
10A91/9/240
11A101/10/240
12A111/11/240
13A121/12/240
14A131/13/240
15A141/14/240
16A151/15/241
17A161/16/241
18A171/17/241
19A181/18/241
20A191/19/241
21A201/20/241
22A211/21/241
Sheet1
Cell Formulas
RangeFormula
C2:C22C2=IF(B2>MAX($E$2:$E$3),1,0)
 
Upvote 0
@etaf I can that in excel as you point out above I am trying to do this in Power query
 
Upvote 0
Assuming you've loaded the table in another query (or as a step in your current one) then you can use
Power Query:
List.Max(queryname[LastPM])
 
Upvote 0
@RoryA thanks I might rename my column in the LastPM table as it was also called LastPM and check the data type is set to date only in case things were not fully qualified
I was using what you suggest st some point and getting errors about not being able to convert table to list and then after more adjustments I would get errors about date conversion
I will report back later with code snippet
 
Upvote 0

Forum statistics

Threads
1,215,077
Messages
6,122,991
Members
449,094
Latest member
masterms

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