Search code examples
google-sheetsgdata

Selecting all rows with distinct column values - Google query language


Consider the following table :

Test Name  Bug name  Status
Name1            Bug1        Fail
Name2            Bug1        Fail
Name3            Bug2        Fail
Name4            Bug3        Fail
Name5            Bug4        Fail
Name6            Bug3        Fail

I want to be able, on a given Google spreadsheet to select all rows containing distinct 'Bug name' columns, so the result should be the following :

Test Name  Bug name  Status
Name1            Bug1        Fail
Name3            Bug2        Fail
Name4            Bug3        Fail
Name5            Bug4        Fail


Solution

  • Assuming you have the example table in range A1:C, I think the expected result could be achieved with this formula:

    =ArrayFormula(iferror(vlookup(unique(B1:B),{B1:B,A1:C}, {2,3,4}, 0 )))
    

    See if that helps ?