omg it worked! The linear search always finds the first hit from top to bottom, but I just need to do the calculation bottom-up and the first value found will be the highest value. So if I have a list of 5 lines A1:B5, then B5 = A5, and B4 =IF(ISERROR(VLOOKUP(A4,A5:B$5,2,0)),A4,VLOOKUP(A4,A5:B$5,2,0) + 1).

Sweet.

Would have been sweeter to just index into SORTED(A1:A5, C1:C5) (assuming the e.g. prices are in C1:C5), but working around this kind of nonsense is kind of fun too on a Saturday morning.