Import selected rows with query on importrange - google-sheets

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'")

Related

Query importrange HUGE multiple sheets and turns out error

so I have 5 separate google sheets, each one with the same title and format enter image description here.
There are 8000-10000 rows each so far, as it's a daily sales updating data, yearly may finish with 20000-40000 rows each.
So what I want to do is to merge all of them into another single sheet, and I've tried the following formulas:
enter image description here
Formula A
={IMPORTRANGE(B2,C2);IMPORTRANGE(B3,C3);IMPORTRANGE(B4,C4);IMPORTRANGE(B5,C5);IMPORTRANGE(B6,C6)}
Results:
#VALUE!
"In ARRAY_LITERAL, an Array Literal was missing values for one or more rows."
Formula B (reduced the data to only one month)
=QUERY({IMPORTRANGE(B2,C2);IMPORTRANGE(B3,C3);IMPORTRANGE(B4,C4);IMPORTRANGE(B5,C5);IMPORTRANGE(B6,C6)},"SELECT * Where Col2 > DATE'2022-5-1' AND Col2 <= DATE'2022-5-31' ",0)
Result:
#VALUE!
"In ARRAY_LITERAL, an Array Literal was missing values for one or more rows."
Formula C (check if is the problem of the code)
={IMPORTRANGE(B2,C2);IMPORTRANGE(B3,C3)}
Results:
It works.
So my question is that, there is anyway via google sheet let me merge all the 5 sheets in one (5sheets*40000rows into one sheet) , or it's not the place to manage that volumn of data?
every importrange needs to be run separately before you use it in your joint formula. the array error you are getting is a result of some importranges importing those 7 columns and those importranges that are not connected output one single cell. make sure you allow access to all your importranges.

Formula parsing error when use Query and Importrange

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")))

Problems with Query Command ORDER BY in Google Sheets

I'm working with one Spreadsheet named "geral" (General, in Portuguese), where I saved all informations and the column A saves the Names of the people. I created another sheet just to see some columns from 'Geral' Sheet, and I entered the following formula in A1 cell:
=QUERY(geral!1:994; "select A,F,L,M order by A"; 1)
. It doesn't work, but if I wrote ... order by A desc it works well.
How can I write the query to see the data in "ABC" order, and not just descending?
Look lower down your sheet. Blanks are being sorted first.

How to use Sumif using range from a complete different Googlesheet/doc

I know how sumif works when I need to access it within the same Google "workbook" (using the analogy from excel). By workbook I mean a collection of sheets, not sure whether there is a different way to refer to Google workbook.
For example in the sheet (Example 3): https://docs.google.com/spreadsheets/d/1Dm-N-1X38zHartE3JbPUtWDnYwEpkGHl6v06huvjSa8/edit#gid=0
I have Sheet2, with column A contain strings and column B containing numerical value. On sheet 1, I have a sumif function which can be query data stored in Sheet2, and sum the cells which match A1 in Sheet1.
The problem starts happening when I try to refer to ranges in a completely different workbook, which is shown below.
I am trying to do a sumif over 2 ranges from a different "workbook". The data is stored here (Example 2): https://docs.google.com/spreadsheets/d/1P5Inf09fLSRmsGbG7LwlE4V-r7DzqY0SB5tJuMKMZH0/edit#gid=0
The Sumif function is in Cell B1 of the following sheet (Example 1):https://docs.google.com/spreadsheets/d/1AitilELd6w7Dbv9d-mKhBYGTBaO6DdkU29Y5mofX2TI/edit#gid=0.
From my understanding importrange is typically used to refer to ranges in completely different workbooks, as a result I use importrange as the first and last arguments in the sumif function in the Sheet Example 1.
What am I doing wrong? Why is this not working?
Can anybody help?
Thanks a lot
See if this query does what you want:
=SUM(query( QUERY( Importrange("1P5Inf09fLSRmsGbG7LwlE4V-r7DzqY0SB5tJuMKMZH0","Sheet1!A1:B10") ) , "select Col2 where Col1 contains '"&A1&"'" ) )

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.

Resources