Google Sheets – Return First Vertical Value Matching Criterion

formulasgoogle sheetsgoogle-sheets-query

On Google Sheets, I would like to figure out a way to have a cell return the first value in column C where the same row in column D matches the criterion ("Blue" for example, as opposed to "Red"). I only need the value that is vertically the highest in column C whose row fits the criterion, since the column is already sorted. Additionally, I will be using this formula on a given sheet (ex. "Sheet A") but referring to data from another sheet which contains the criteria ("Sheet B" for example). Sorry, I'm a bit new to arrays and/or complicated formulae in Sheets.

Best Answer

  • for numbers:

    =QUERY(C:D, "select C where D = 5 limit 1", 0)

  • for text:

    =QUERY(C:D, "select C where D = 'red' limit 1", 0)