Search code examples
google-sheetsgoogle-sheets-formula

Google Sheet get the most recent entry based on criteria


I am not an excel spreadsheet expert or google sheet expert and I have a spreadsheet where I keep track of my workout progress on a google sheet. I keep track of the weight and the reps per set on a weekly basis. Every week, I have to keep going back and finding the most recent entry. This becomes time consuming when there's more entries, and different type of exercises that are recorded. Is there a formula to retrieve the most recent entry based on a set of criteria?

enter image description here

So on the above data, I would get... 135 & 8 for the weight & rep for the 1st set, 135 & 8 for the weight & rep for the 2nd set, so on and so forth...

enter image description here

Any help would be great! thank you

I tried QUERY, MAXIFS,SORTN, SORT but to no avail does not return the correct result.

enter image description here

=sortn(sort('Workout Journal'!A:E,5,false),99^99,2,2,false)

=QUERY('Workout Journal'!A:N,"select C where A="Barbell Squat' and E=date '"&TEXT(DATEVALUE(max('Workout Journal'!E2:E)),"yyyy-mm-dd")&"'"))))

Solution

  • I did figure it out and quite very simpler than what I thought!

    So in the template sheet, for

    To get the Last Entry for Weight

    =MAXIFS('Workout Journal'!C:C,'Workout Journal'!A:A,A277,'Workout Journal'!B:B,B277,'Workout Journal'!E:E,MAXIFS('Workout Journal'!E:E,'Workout Journal'!A:A, A277))
    

    To get the Last Entry for Reps

    =MAXIFS('Workout Journal'!D:D,'Workout Journal'!A:A,A277,'Workout Journal'!B:B,A277,'Workout Journal'!E:E,MAXIFS('Workout Journal'!E:E,'Workout Journal'!A:A, A277))
    

    enter image description here