Search code examples
regexif-statementgoogle-sheetsgoogle-sheets-formulaarray-formulas

Seeking First High in Column


Not needing max value in array, but rather first high. For me, a high must be greater than the one following (next row up) and greater than the one preceding(next row down) less one.

I have two examples in this sheet, but don't know how to structure a single cell formula to return desired result. https://docs.google.com/spreadsheets/d/185zQHX0P2KC41DBuHHbv7K4onCdroTDKjT0DSKSM1IU/edit?usp=sharing

Listed in the sheet examples.


Solution

  • Just for comparison, this would be the more conventional index/match approach with offset ranges:

    =ArrayFormula(index(M45:M49,match(1,(M45:M49>M44:M48)*(M45:M49>(M46:M50-1)),0)))
    

    More generally using index with a named range:

    =ArrayFormula(index(index(range,2):index(range,rows(range)-1),match(1,( index(range,2):index(range,rows(range)-1)>index(range,1):index(range,rows(range)-2) )*( index(range,2):index(range,rows(range)-1)>index(range,3):index(range,rows(range))-1) ,0)))
    

    enter image description here