Reputation: 4506
looking for a function that will do the following:
Sheet 1:
| **Title** | **Genre** | **Rel** |
| Breaking Bad | Action/Drama | x |
| Homeland | Drama | 2020 |
Sheet 2:
| Breaking Bad | Action/Drama |
Is there such a formula to give me the sheet with all titles + genres in which there is an x in the the rel column.
I've tried with
=QUERY(Sheet1!A2:C, "select A,B where (C = 'x')")
but that gives me a lot of results in the first row in the first and second cell which shouldnt be there and then correct results in the rest of the rows. What is going on in the first cell?
Upvotes: 0
Views: 35
Reputation: 24609
but that gives me a lot of results in the first row in the first and second cell which shouldnt be there and then correct results in the rest of the rows. What is going on in the first cell?
The third argument of QUERY is optional and stipulates how many header rows are in the source data. If this argument is omitted (as you have done), then Sheets will guess how many header rows there are, and sometimes guess wrong.
The solution is to always include that third argument; as you are referencing from row 2, I presume that your source data has no header rows:
=QUERY(Sheet1!A2:C,"select A, B where C = 'x'",0)
Upvotes: 1