I have a gsheet with columns out to AC, most of which are filtered from another sheet which is, in turn, imported from an external source. The relevant columns are:
Row 3 is header information Row 4 (a hidden row) is where my ArrayFormulas are located for other columns Row 5 is where data begins (and continues for several hundred additional rows) For each key found in column J, I want to identify the largest value of K and return it in C, and I want to do this using an ArrayFormula, so that I only need to specify it once at the top.
Example set for primary goal Example set for stretch goal
What I've come up with so far, for the primary, is
=ArrayFormula(maxifs(K4:K,J4:J,"<>"&"",J4:J,"="&J4))
which, of course, did not work as expected. I have not even begun to consider the stretch goal (since I'd have modified the other after it worked... which it isn't)
Any recommendations?
(edit to put in images of data set instead of the oddly formatted stuff that didn't actually work)
Try this in C4 of an otherwise empty C4:C:
=ArrayFormula({"Header"; IF(J5:J="",,IF(VLOOKUP(J5:J,SORT(J:K,2,0),2,FALSE)=K5:K,K5:K,F5:F))})
You can change the header in the formula as you like.
The rest basically says this: "If J is null, return null. Otherwise, look up J in J:K reverse-sorted by K (i.e., highest values at the top). If what is found matches what is already in the row, return K; otherwise, return F."
ADDENDUM (based on updated information in original post):
=ArrayFormula({"Header"; IF(J5:J="",,IF(VLOOKUP(J5:J,SORT(J:K,2,0),2,FALSE)=K5:K,K5:K,VLOOKUP(J5:J,SORT({J:K,F:F},2,0),3,FALSE)))})