user3228457
user3228457

Reputation: 107

How to use query in Google spreadsheet to select column instead of row?

Please, need your help !!!

I tried

=query(A1:E6, "select * where D = 'Yes'", 0)

it will select the rows which in column D that has value 'Yes'.

My question is: how to select the columns which in row 2 that has value 'Yes'. I tried:

=query(A1:E6, "select * where 2 = 'Yes'", 0)

but it does not work :(

Upvotes: 9

Views: 23154

Answers (2)

AdamL
AdamL

Reputation: 24619

To do this with QUERY, you would need to do a double TRANSPOSE, or use an alternative like FILTER.

=TRANSPOSE(QUERY(TRANSPOSE(A1:E6),"select * where Col2 = 'Yes'",0))

or

=FILTER(A1:E6,A2:E2="Yes")

Upvotes: 13

James Bond
James Bond

Reputation: 3017

Well it can be so simple, and we can use google query SQL features too:

Excel Table:

     A       B
1    Qty   | 200
2    Stock | QUESS
3    Start | 8/24/2019
4    End   | 8/23/2020
5    Today | 8/23/2021

Formula:

=query(Transpose(Sheet6!A1:B5),"select *" )

Output :

Qty | Stock | Start     | End       | Today
200 | QUESS | 8/24/2019 | 8/23/2020 | 8/23/2021

Note : A similar discussion here : [https://stackoverflow.com/questions/63044551/google-sheets-transpose-query/68901704#68901704]

Upvotes: 0

Related Questions