So close to DMAX solution

Okay, so I’m on LibreOffice Calc 4.2.8.2 in English…

I’ve got one very simple sheet that is to be a ‘review_log’… with two columns and data entered…

Date          | Who
4/12/13    |   Joshua
4/12/14    |   Joshua
4/12/15    |   Joshua
3/2/15      |   James

Etcetera, with names and dates entered forever and the list getting longer.

On another sheet, I enter in the first column just the name, in the test case, Joshua… and I need to get the date of the LAST (chronologically) entry for that name. The closest I’ve come uses DMAX…

A                    B
1  | Who           |   Last Review
2  |  Joshua       |   =DMAX('review_log'.$A$2:$B$1003,"Date",{"Who";"Joshua"}

Now right now, this DMAX works! However, the name “Joshua” is hard coded into it. I need this function to work dynamically so that “Joshua” in the criteria array is replaced with the value of A2… I have tried simply putting A2 there, “A2”, =A2, “=A2”, using the cell function… and I can’t get anything to work!

Anyone have any ideas? :slight_smile:
Thank you all so much!

[edit]

Thanks to a brilliant function by pierre-yves samyn, I am so so close to having this document fully functional! The problem is I need to pull another piece of data out along with the date! Here is the actual spreadsheet I’m stuck on for clarity. It’s the first sheet (“current”), column F is all that’s left, with the solutions for C and E already found!

council record.ods

This forum is amazing! Thank you all, I had nearly given up hope this was possible!
–Joshua

[edit]

So in using this sheet we’ve found a bug, which happens when two entries on the advocacy log page have the same date. As shown in this file, the F9 cell on the ‘current’ tab should read Joshua, based on the entries in the ‘advocacy log’ tab. I would really appreciate any solutions you can come up with, I’m at a loss.

council record.ods

Interestingly, I have determined that the cleanest solution, which doesn’t work in Calc, DOES work in google sheets! It accepts A3 instead of “Joshua” in the {} syntax, generating the array dynamically and functioning perfectly.

= IF (
$A5 <> “”,
MATCH (
IF (
AND (
‘advocacy log’.$B$3:$B$1003 = $A5,
‘advocacy log’.$A$3:$A$1003 = $E5
),
$A$1003:$B$1003
),
‘advocacy log’.$C$3:$C$1003
)
, “”
)

get’s #N/A… good approach?

set up →Data→Pivottable...

drag&drop Who into Rowfield, drag&drop Date into Datafield, change Aggregatfunction from sum to max and hit ok

or change your Formula to:

=DMAX('review_log'.$A$1:$B$1003,"Date",A1:A2)

So, I did try that (making the array A1:A2) and it does work… however it works ONLY for the first name. There will be a whole list of names which need to pull data from the log, and so it needs to work for all of them…

The other solution (Pivottable)… Hmm… a little confused, but trying…

Sorry, I still don’t get it. Do I use the review_log as the data set for the pivot table? How does that interact with the function that pulls the data from the log?

however it works ONLY for the first…

thats the reason for using Pivottable start from one cell in Source.

“…names and dates entered forever
and the list getting longer.”

You are using the wrong kind of app for this kind of data. You need to use a DB (database) App, else one day you will likely run out of memory.

It’s true that a database would be better… however the rate at which this will grow is very slowly… maybe one or two lines per month, so I figure this will work for a damn long time, neh? (that is, if I can figure out this formula!)

Hi

Pivot Table is the simplest solution, so the best IMO. Just for fun a (very) complicated formula solution.

I tried to explain in the spreadsheet itself.

FindMax.ods

[EDIT]

New version with formula for col F (I hope I have understood your request?)
council recordPys.ods

Regards

That is very interesting, and I think it solves my problem… I am still working on understanding this solution…

Okay, that is absolutely brilliant. It works perfectly. I don’t completely understand it, but I’ve managed to implement it. Not only did you solve the question I asked, but you solved a problem I hadn’t even thought to try and solve, that of creating the “current” list of who is actually here, which I thought fine to maintain manually. Fantastically done, man! I’m working on adapting it to the rest of the sheet now! Thank you!

What if I need to pull another piece of data out of the log? I need to pull another column out of the log, on that same row as the last date, while still matching the name. Even now having the date in question and the name I can’t figure out how to have two criteria in the search. DMAX could do it, but only if we could dynamically generate the array, so I’m back to the same problem! If we could return the row in question, I could use offset. Any insight?

You are absolutely fantastic. It works! I’ve been beating my head against this wall for ages, and you’ve completely solved it. I can’t thank you enough!

So we’ve been really using that sheet, and have found a bug in the F column, which happens when two entries on the advocacy log tab have the same date (which happens frequently), as shown in the file I am editing the question to add. I can barely understand that brilliant formula you built and hoped you could chime in with a fix for this bug, please. :slight_smile: