user15240243
user15240243

Reputation: 27

Query + Importrange with column selection to display matching a non-displayed criteria

I am trying to do the following:

  1. Bring information to a Google sheet from another Google sheet using importrange.
  2. I need the information of two columns, but bases on the criteria of a third column I do not need to display.

This is what I already tried to do:

Script

=query(importrange("Link1","Sheet!b1:h"),"SELECT G, H where B = "Criteria_to_meet"",-1)

But it does not work.

Upvotes: 0

Views: 198

Answers (2)

user15240243
user15240243

Reputation: 27

Thanks for your help. Your comments were very usesful. This is how it finally worked.

Cell A1 contains criteria_to_meet, and we expanded the importrange to contain the first column.

Formula

=QUERY(importrange("Link1","Sheet!A1:H"),CONCATENAR("SELECT Col7, Col8 WHERE Col2='",A1,"'"),1)

Upvotes: 0

Aresvik
Aresvik

Reputation: 4630

Since the query is loading data via importrange, you need to use the other select notation, Col1,Col2 rather than A,B.

Hence, instead of select G,H where B you would use select Col7,Col8 where Col2.

In addition, "Criteria_to_meet" would most likely need to be ""Criteria_to_meet"" (double quotes x 2) or 'Criteria_to_meet' (single quotes).

Upvotes: 1

Related Questions