0
votes

I would like to automatically find the latest date in a row, in a Google Sheet which contains several possible columns for dates to be in. My dummy sheet is here:

https://docs.google.com/spreadsheets/d/1j9pRECnAKtKtvAfhMvLv93-u6_kwIrFZg3RY3jSkpkU/edit?usp=sharing

The date columns (E:G) are blank until they are filled in with dates for a particular row (each row is a person, the dates are dates they do a particular thing A B or C). I currently have a column "lastPersonContact" which calculates the latest date in the range for that row using MAX(). I want this formula to spread to new rows automatically, since my dataset is so large and gets arbitrary numbers of rows added to it all the time. The problem is that I only know how to use ArrayFormula to calculate the max of either one row, or the entire range of columns in all rows, which means that my ArrayFormula code returns the same value for all rows (the max of all dates in all rows) instead of the latest date for that particular row.

You can see my attempt at making this work (which does not work) in Column O. The output that I want is correct in Column D, but does not automatically fill down.

1

1 Answers

1
votes

I think this should work for you. It builds a 2d array using SPLIT() and FLATTEN() and then query's to find the max per row. then does a vlookup of the row into that query.

=ARRAYFORMULA(IF(A2:A="",,VLOOKUP(ROW(A2:A),QUERY(SPLIT(FLATTEN(ROW(A2:A)&"|"&E2:G),"|",0,0),"select Col1,MAX(Col2) group by Col1"),2,0)))