Formula parsing error when use Query and Importrange - google-sheets

I need to import data from another sheet, but only even-numbered rows (has a number in column A in addition to the spreadsheet numbering).
I'm using importrange and query to make this filter, but I'm experiencing the following error: "Formula parsing error".
This is the query I'm trying to use:
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1oI0NsjQnf1Grh59HSei64c5F6nuqnjyGSQCXvLJbcmA", "Página1!A2:J1000"),"SELECT * WHERE (A % 2) = 0")
This command only:
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/1oI0NsjQnf1Grh59HSei64c5F6nuqnjyGSQCXvLJbcmA";"Página1!A2:J100")
works, so the problem would be with my Query.

use:
=FILTER(IMPORTRANGE("1oI0NsjQnf1Grh59HSei64c5F6nuqnjyGSQCXvLJbcmA"; "Página1!A2:J");
ISEVEN(IMPORTRANGE("1oI0NsjQnf1Grh59HSei64c5F6nuqnjyGSQCXvLJbcmA"; "Página1!A2:A")))

Related

Col BY causing parse error in Google sheets query

I'm trying to run the following Query in google sheets, but am receiving a parse error when I try to select the column BY. Without this column, it runs as expected.
Query below:
=QUERY('Applications received'!B:DL,"Select B,CT,CU,CV,CW,CX,BY where B is not null order by CX")
Any help is much appreciated!
BY column needs to be escaped with `:
=QUERY('Applications received'!B:DL,
"select B,CT,CU,CV,CW,CX,`BY`
where B is not null
order by CX")
https://developers.google.com/chart/interactive/docs/querylanguage#reserved-words

QUERY with IMPORTRANGE returns "Unable to parse query string ..."

We are currently trying to set up the following formula:
=QUERY(IMPORTRANGE("1uyazplHdGpZeBZWOv3TbnIUfWeHQGyZF5mRsNuWxkO4","Data Salesforce!A:Z"),"Select A Where J = 'Spain'",-1)
The idea is to look for a QUERY with data coming from an IMPORTRANGE.
We get the following error:
Unable to parse query string for Function QUERY parameter 2:
NO_COLUMNA
Any idea how we could resolve it?
Instead of identifying the columns by Alphabetical index you need to reference them by numerical index.
I assume this is because importrange() doesn't really import the range but just the values.
Try
=QUERY(IMPORTRANGE("1uyazplHdGpZeBZWOv3TbnIUfWeHQGyZF5mRsNuWxkO4","Data Salesforce!A:Z"),"Select Col1 Where Col8 = 'Spain'",-1)

Import selected rows with query on importrange

I'm trying to import select rows from a Google spreadsheet based on the value of a single cell in each row.
As such, I'm using the following:
=query(IMPORTRANGE("KEY","Form Responses 1!A:L"), "select * where J contains 'DENIED' ")
Wherein the KEY is an actual spreadsheet Key. I tested the importrange part, that is without the query, to confirm it works. It does. Furthermore, within the Google Spreadsheet itself I can query the sheet and get it to work.
The error I receive is:
#VALUE Error Unable to parse query string for query parameter 2: NO_COLUMN_J
(There is a column J.)
When you use an importrange as a dataset, you need to refer to the columns by number rather than letter. The formula also works without 'select *'. Try:
=query(IMPORTRANGE("KEY","Form Responses 1!A:L"),"where Col10 contains 'DENIED'")

Combining multiple spreadsheets in one using IMPORTRANGE

I would like to aggregate the data of multiple spreadsheets into one spreadsheet.
Spreadsheet 1 has a Row of Strings A2:A500
Spreadsheet 2 has a Row of Strings A2:A500
Spreadsheet 3 is supposed to have a Row of both (Spreadsheet1!A2:A500 AND Spreadsheet2!A2:A500).
Duplicates shall not be handled differently. I would like them to appear as often as they appear in the different sheets.
Is it possible to do this without writing a script or using jQuery, e.g. by using IMPORTRANGE?
What does not work: I have tried using IMPORTRANGE as follows:
ARRAY{IMPORTRANGE("key-of-spreadsheet1","list!A2:A500"), IMPORTRANGE("key-of-spreadsheet2", "list!A2:A500")}
This causes an error.
You should be able to use a vertical array in the Spreadsheet 3:
={IMPORTRANGE("Sheet1Key","SheetName!A2:A500");IMPORTRANGE("Sheet2Key","SheetName!A2:A500")}
Of course, it is also possible to combine several IMPORTRANGE() functions with the QUERY() function, which gives us a greater control over the results we import.
For example, we can use such a construction:
=QUERY(
{
IMPORTRANGE("key-or-url-of-spreadsheet-1", "'sheet-name-1'!A2:Z100");
IMPORTRANGE("key-or-url-of-spreadsheet-2", "'sheet-name-2'!A2:Z100");
IMPORTRANGE("key-or-url-of-spreadsheet-3", "'sheet-name-3'!A2:Z100");
IMPORTRANGE("key-or-url-of-spreadsheet-4", "'sheet-name-4'!A2:Z100")
},
"SELECT * WHERE Col1 IS NOT NULL ORDER BY Col3 ASC"
)
###Explanation:
The above query removes blank lines from imported ranges:
SELECT * WHERE Col1 IS NOT NULL
and sorts ascending all data collected together in relation to the third column:
ORDER BY Col3 ASC
For descending, just use DESC in place of ASC.
Of course, we can also arrange any other criteria, or omit them displaying everything without modification:
"SELECT * "
###Note:
In order to use the above constructed query, we first need to call a single IMPORTRANGE() method for each of the spreadsheets we want to refer:
=IMPORTRANGE("key-or-url-of-spreadsheet-1", "'sheet-name-1'!A2:Z100")
We have to do this even if we refer to the same spreadsheet in which we write this formula, but for every spreadsheet it is enough to do it once.
This is to be able to connect these sheets and allow access to the sheets (to which we have the access rights anyway):
                                                    
After giving permission for all spreadsheets, we can use the above query.
I am also applying above given formula for getting data from multiple spreadsheet which is getting an error something is like IN ARRAY_LITERAL An array literal was missing values for one or more rows.
Easy fix: Apply the filter to the entire column / sheet instead of just the current selection. This will automatically update all of the filters to include new additions.

How to use IFERROR inside an array formula?

If any of the queries in an array formula do not have actual data to query in the range they are hitting they return #VALUE! and mousing over the array formula reveals an error. If I take those queries and wrap them in an IFERROR I get the same results.
If I take what I wrapped in an IFERROR and split it out into its own cell to validate the query it results in displaying the error clause which in this case is a 0.
Here is a link to an example sheet.
Sheet1 has sample data.
Sheet2 is intentionally blank to simulate the issue described above.
Sheet3 has three queries on it in various states. The top two are the array formulas I am attempting to work with. The bottom Query is the IFERROR split out into its own cell to show that the query does in fact work when separated from the rest of the sort(arrayformula(etc)).
Try combining both ranges (from both sheets) inside 1 query instead of using 2 queries, and wrap an IFERROR() around that single query:
=ARRAYFORMULA(IFERROR(QUERY({Sheet1!A1:I500; sheet2!A1:I500}, "Select * where Col7='no'", 0), 0))
See if that works for you ?

Resources