0

I Have a table in my spreadsheet like this

FEB  MAR  APR  MAY
 10   14    7   13
 12    9    8   19
 15   11   14   16

And I want to use this info in another table. What I want to accomplish is in this another table compare two months by getting this info with the name of the month.

FEB  APR
 10   7
 12   8
 15  14

What I did was

=QUERY(AnotherTable!1:1001; "SELECT * WHERE Row2 = 'FEB'")

But it didn't seems to work.

Any thoughts?

Rubén
  • 34,714
  • 9
  • 70
  • 166
Felipe
  • 35
  • 4
  • The question isn't clear enough because the formula doesn't include the filtering criteria to get two columns, it only includes `FEB` while `FEB` and `APR` columns are shown in the "another table". – Rubén Mar 09 '16 at 23:27

2 Answers2

1

You might be able to use a FILTER formula instead:

=FILTER(AnotherTable!1:1001;AnotherTable!2:2="FEB")

or to return both months:

=FILTER(AnotherTable!1:1001,((AnotherTable!2:2="FEB")+(AnotherTable!2:2="APR")))

Chris Hick
  • 3,004
  • 1
  • 13
  • 15
  • This will not return the desired result. The source data has four columns; the OP wants two columns as result, one with FEB and another with APR in the first row. – Rubén Mar 09 '16 at 22:01
  • 1
    The example formula in OP was looking for 'Feb' only. This version will bring back both months : =FILTER(AnotherTable!1:1001,((AnotherTable!2:2="FEB")+(AnotherTable!2:2="APR"))) – Chris Hick Mar 09 '16 at 23:01
  • The formula in OP is about what the asker already tried. He said that "it doesn't work" but he doesn't explain what was wrong with it. Anyway, the question isn't clear because the formula doesn't include both filtering criteria.. I think that your formula in the comment should be included in your answer. – Rubén Mar 09 '16 at 23:23
  • agreed, I wasn't clear on whether OP wanted a formula to extract each month separately or a combined output with both months showing. I've edited answer to include both options. – Chris Hick Mar 09 '16 at 23:34
  • You are right, showing two columns in the "another table" doesn't mean that both columns are returned by a single formula. – Rubén Mar 09 '16 at 23:40
  • Sorry that I wasn't clear enough. But the FILTER did the trick. Thank you @ChrisHick – Felipe Mar 10 '16 at 12:39
1

Use TRANSPOSE built-in function two times, the first to flip the source data, the second to flip the result, and instead of referencing rows, the formula should reference columns.

The resulting formula is

=TRANSPOSE(QUERY(TRANSPOSE(A:D),"Select * where Col1='FEB' OR Col1='APR'"))

Applying the above formula to the following source data

FEB  MAR  APR  MAY
 10   14    7   13
 12    9    8   19
 15   11   14   16

will return the following result

FEB  APR
 10   7
 12   8
 15  14
Rubén
  • 34,714
  • 9
  • 70
  • 166