Google Sheets Query combining data source - google-sheets

I don't know why but when put two sources in QUERY command, I get #ARG! error. Can somebody tell me why?
https://docs.google.com/spreadsheets/d/1jzhsqVD5oeokraoKcu4C2AnnlzBBVvbD_lONBKrgk-I/edit#gid=387365472

You cant ref to A, B [..] when merged input data use Col1, Col2 [..]

Related

Attempting to Merge data and sum up the similar items. After a Filter/Sort within Google Sheets

Currently working on a project where im trying to Filter out and Sort out data from one list based on a dropdown menu. When the data gets pulled from the other list into a better readable format, it brings along some duplicate item names due to being listed seperately based on SKUS, is there any way i can SUM the total qunatities together, and have just 1 name within that list via Functions?
my current function is
=SORT(FILTER('Month of Detailed Manifest Report'!B2:D, 'Month of Detailed Manifest Report'!A2:A = A3, 'Month of Detailed Manifest Report'!B2:B <> "SAMPLES"),1,True)
Brings my data up like this.
You can see how it adds Duplicate Data Here
Just trying to get it so it merges the similar names and adds the Qty's together so i can get a better accurate data pull of information.
See my comment to your original post. That said, just eyeing it here and without the ability to test it, you can try this formula:
=QUERY({'Month of Detailed Manifest Report'!A2:D},,"Select Col2, Col3, SUM(Col4) WHERE Col1 = '"&A3&"' AND Col2 <> 'SAMPLES' GROUP BY Col2, Col3 LABEL SUM(Col4) '' ORDER BY Col2")
In theory, that should work.
If not, as I invited in my previous comment, share a link to a copy of the spreadsheet.

Google Sheets QUERY IMPORTRANGE formula

enter link description hereI'm trying to get a return of all Active jobs but I keep getting the error message #value!; "Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: A". Here is the formula I used.
=QUERY({IMPORTRANGE("SheetKey","employeeName1!A18:V1000"); IMPORTRANGE("SheetKey","employeeName2!A19:V1000");IMPORTRANGE("SheetKey","employeeName3!A19:V1000");IMPORTRANGE("SheetKey","employeeName4!A19:V1000")},"SELECT A, B, C, D, E WHERE E = 'Active'")
I tried replicating your issue by making a copy of your provided sample sheet but apparently, the formula works after making a copy of the sheet. Please see attached screenshot.
I suggest trying to copy it first making a new sheet with the same content and see if it will also solve your problem.
use:
=QUERY({
IMPORTRANGE("SheetKey", "employeeName1!A18:V1000");
IMPORTRANGE("SheetKey", "employeeName2!A19:V1000");
IMPORTRANGE("SheetKey", "employeeName3!A19:V1000");
IMPORTRANGE("SheetKey", "employeeName4!A19:V1000")},
"select Col1,Col2,Col3,Col4,Col5
where Col5 = 'Active'")
I took out the IMPORTRANGE and just used a query formula for the other sheets and it worked perfect. Thanks for the input everybody.

How to use absolute references in google sheets query formula or query by column names for multiple sheets?

I have the following problem. I'm trying to write query formula in order to put all values in one sheet by typing yes in one column, however, I have the following problem. Whenever I add a new column, references in query formula (multiple sheets) are changing and the formula doesn't work. How can I prevent this?
Or is there any way to query by a column name in multiple sheets?
I have tried locking relative references by putting sign $
I have tried to use an indirect formula to take references (data set in Helper TAB, cell E2) - nothing worked
I'm out of the ideas, for now, anyone knows how to fix this?
=QUERY({'Sheet 1'!$A:$Z;'Sheet 2'!$A:$Z;'Sheet 3'!$A:$Z;'Sheet 4'!$A:$Z}, "select * where Col1 ='yes'",0)
Here is the file I did, you can see query formula in Master sheet:
https://docs.google.com/spreadsheets/d/1XD-CECy5W5-HM5EkBFJQKDtLlykQq8Cj8ZOvDUXkd1s/edit?usp=sharing
A solution to the problem is to use a formula that searches for the column address based on a reference.
=SUBSTITUTE(ADDRESS(1;COLUMN(A1);4);"1";"")
This formula will return the value A, which is the column of address A1.
It can be used in query functions like this:
=QUERY(A:D;"SELECT "&SUBSTITUTE(ADDRESS(1;COLUMN(A1);4);"1";"")&"")
This function is equivalent to the function:
=QUERY(A:D;"SELECT A")

How to concatenate strings and select the same columns multiple times using Query (Google Sheets)

I am trying to generate a table for the Gantt chart. Table should have this format:
https://developers.google.com/chart/interactive/docs/gallery/ganttchart#data-format
So,I need task name the same like taks ID, but in Query I can't use Col1 twice (I get error)
=QUERY({Tab1;Tab1};"select Col1,Col1,Col5,Col16,Col17 WHERE Col16>now() ORDER BY Col5 DESC,Col17 ";0)
The second point is that it is also not possible to merge two columns as a result, so it doesn't work:
=QUERY({Tab1;Tab1};"select Col1+Col7,Col1,Col5,Col16,Col17 WHERE Col16>now() ORDER BY Col5 DESC,Col17 ";0)
Here is my data and 2 results what I neet to get by QUERY
https://docs.google.com/spreadsheets/d/1CZYgfYo6oIeONZOH6ZR5rOW615HuH4ICaoe7lj0dapw/edit#gid=0
These are such trivial things in a real SQL, is there no way to do it somehow straightforwardly in Google Query? So far I have found a combination of QUERY and ARRAYFORMULA but then there are very complicated queries - mutants. Not easier?
You don't need Query, just Arrays.
You will get the first result from this code:
={ARRAYFORMULA(B3:B&" "&C3:C)\A3:A}
The second result from this code:
={A3:A\A3:A\B3:B1}
Based on your example I assume that you are not using US spreadsheet settings.
If so formulas have to be change to:
First:
={ARRAYFORMULA(B3:B&" "&C3:C),A3:A}
Second:
={A3:A,A3:A,B3:B}
Link to working example: https://docs.google.com/spreadsheets/d/1eMkOkyFwvDeYSy-8UlhQum4OWcb-4WJqGxy_CXM8pVs/edit?usp=sharing
I see that in your real sheet you would like to compare some data with now(). You can easily do this using array I propose as a source to Query. There will you have something like this (of course now it will not work - its only an example - an array have only 2 columns, not 15):
=QUERY({ARRAYFORMULA(B3:B10&" "&C3:C10)\A3:A10};"select * where Col15>now()";0)
About Query - you can't perform arthmetic operations on column containing strings. Look at the documentation: https://developers.google.com/chart/interactive/docs/querylanguage#arithmetic-operators
"I can't use Col1 twice (I get error)"
You can duplicate your indata that to solve this.
QUERY({Tab1 Column 1\Tab1 Column 1};"Select Col1, Col2......"
"Tab1 Column 1" is now Col1 and Col2
"The second point is that it is also not possible to merge two columns as a result, so it doesn't work:"
Yes, adding result of column is possible "select Col1+Col7......" is correct.

IS NOT NULL - A simple google sheets query issue

I want my google sheets query to just filter out the rows with a blank value and possibly the ones containing specific words as well
Here's an example spreadsheet, I've tried using "where B is not null" in the query but it's not working! I'm tearing my hair out over this as i'm sure it's a simple solution.
https://docs.google.com/spreadsheets/d/1xZH1MKeqLa8r1gRGL9wYHEWe02wQoNNpqqL_ca1fGf0/edit?usp=sharing
Thanks in advance for your help!
you may need to test for empty string instead of null, you can add AND to remove other values:
=QUERY(A2:B6,"select A, B where B<>'Pizza' and B<>''")
This just worked for me
=QUERY(A2:B6,"select A, B where B!='' ",0)

Resources