Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to take only certain columns from a FILTER result?

I'm using FILTER to extract rows from a range, and want to take only certain columns. For example, I filter by D, but want only columns B,C in reverse order. I tried to use QUERY:

=QUERY(filter(B:D,D:D>=2), "select C,B") - Error: can't analyze query string for function QUERY parameter 2: NO_COLUMNC
=QUERY(filter(B:D,D:D>=2), "select *") - shows me all columns, so QUERY should work...

How do I QUERY the results of FILTER? Any other way to achieve this?

like image 680
Jonathan Avatar asked Nov 06 '14 09:11

Jonathan


People also ask

How do you filter columns separately?

Copy the single column or subset to an out of the way spot so you can sort it separately from the source spreadsheet. To do this, select the column you want to sort by clicking the column's header cell. Next, choose Filter from the Data menu and then select Advanced Filter.

How do I select only certain columns in Excel?

To select non-adjacent rows or columns, hold Ctrl and select the row or column numbers.


1 Answers

When you are QUERYing a computed array, you need to use the Colx notation rather than column letters:

=QUERY(FILTER(B:D,D:D>=2),"select Col2, Col1")

which incidentally can be achieved by just using the QUERY:

=QUERY(B:D,"select C, B where D >= 2")

or just FILTER:

=FILTER({C:C,B:B},D:D>=2)

like image 124
AdamL Avatar answered Oct 04 '22 04:10

AdamL