Google Sheets – Find Max Value After Column Operations

formulasgoogle sheetsgoogle-sheets-arrayformulagoogle-sheets-queryvlookup

I have a Google Sheets with a column D with identifiers in a certain format (i.e. Y19_XXX):

Y19_234
Y19_213
Y19_814
Y19_215
Y19_817
...

Now I want to determine the highest value XXX in that column that is lower than 800 (here in this example thus 234).

I tried: =MAXIFS(ARRAYFORMULA(VALUE(RIGHT(D3:D300,3))),ARRAYFORMULA(VALUE(RIGHT(D3:D300,3))),"<800"), but the MAXIFS formula complaints it needs a range to operate, while I thought the ARRAYFORMULA(VALUE(RIGHT(D3:D300,3))) formula resulted in a range.

Anyone an idea?

Best Answer

=ARRAYFORMULA(VLOOKUP(QUERY(SPLIT(A2:A, "_"), 
 "select max(Col2) where Col2 < 800 label max(Col2)''", 0), 
 {INDEX(SPLIT(A2:A, "_"), , 2), A2:A}, 2, 0))

0