Importrange + query formula - google-sheets-formula

Can anyone help? I'm trying to create a separate sheet that would automatically import the data from this source sheet below using importrange and query formula.
source sheet
I want to import specific column (columns A, E & F) data only if the column G is equal to "EUR". Here's my formula but it's not working for me.
=QUERY(IMPORTRANGE("this is where i put my source sheet URL","All Orders!A2:G1000")"select=col1,col5,col6 where col7=EUR") )

Try this:
=QUERY(IMPORTRANGE("this is where i put my source sheet URL","All Orders!A2:G1000"),"SELECT Col1, Col5, Col6 WHERE Col7='EUR'") )
Col is case sensitive and when you are comparing to a string you need to wrap it in single quotes.

Related

How to add additional column showing sheet names & row source in query importrange function (google sheet)

I have a query importrange function to combine hundreds of my sheet into 1 new googlesheet file, but i need an additional column which show sheet/tab source name and the row source.
this is my query so far :
=QUERY(
{IMPORTRANGE("SheetID-1","Sheet1!A5:Y1000");
IMPORTRANGE("SheetID-2","Sheet2!A5:Y1000");
IMPORTRANGE("SheetID-3","Sheet3!A5:Y1000")},
"SELECT * WHERE Col2 IS NOT NULL Order By Col1", 0)
my query is like that (but for hundreds different sheet) and now i hope i can added aditional column in column Z that showing the source tab/sheet name with row :
Example :
Column Z : Sheet1 - Row 7
If i using filter i can add the additional column with the source row & sheet name like that, but im have no idea to add the column using query. Need some help here.

Sorting received data from query

I have a Google Sheet where in sheet B C D E data gets entered and exported to sheet E via a query.
But it sorts it per sheet and not mix them in order.
I don't want a date order of sheet B then sheet C.
I need it that 1-1-23 on sheet D is in front of 31-12-2022 from sheet B
This is the query formula I use now
=QUERY({SheetB!A2:N;SheetC!A2:N;SheetD!A4:N;SheetE!A5:N},"select * where Col1 is not null",0)
Col1 is the column with the dates in it which need to be sorted.
I tried sorting via the Sort A-Z method that is not working I also tried to add Sorty By Col1 as shown below
=QUERY({SheetB!A2:N;SheetC!A2:N;SheetD!A4:N;SheetE!A5:N},"select * where Col1 is not null",0,Sorty By Col1)
Example sheet:
https://docs.google.com/spreadsheets/d/1gQUkJUW8ChWj59vtDu64rI1ozZjY6b5ABmzns6lgF9o/edit?usp=sharing
try:
=QUERY({SheetB!A2:N;SheetC!A2:N;SheetD!A4:N;SheetE!A5:N},"select * where Col1 is not null ORDER BY Col1 DESC",0)

Importing total sum of one column filtering multiple values of one column

I am trying to import the total sum of one column filtered with some conditions. The problem is when I want to add 2 or more conditions to one specific column.
Below my formula:
QUERY(IMPORT RANGE("File","Data Base!A1:R10000"), "Select Sum(Col6) where Col1 = '"&$E$36&"' and Col10 = '"&$E$38&"' and Col17 = '"&$B44&"' label sum(Col6)''")
I want also Column 10 will be equal to E38 and also E39. How can I modify the formula to be able to consider cell E39?

Google sheets query in need of a ifs statement

I am trying to select different column depending on the column where a certain string is found.
This is my curent query.
=QUERY(IMPORTRANGE(Configuration!I5,"Employes!A2:Z"),"select Col26, Col3 where Col16 = '"&D27&"' or Col18 = '"&D27&"' or Col20 = '"&D27&"'")
Right now, it brings only 2 columns of data, but I would need it to also bring the columns following the one where it will find the sting "D27".
Try
=query({
QUERY(IMPORTRANGE(Configuration!I5,"Employes!A2:Z"),"select Col26,Col3,Col16,Col17");
QUERY(IMPORTRANGE(Configuration!I5,"Employes!A2:Z"),"select Col26,Col3,Col18,Col19");
QUERY(IMPORTRANGE(Configuration!I5,"Employes!A2:Z"),"select Col26,Col3,Col20,Col21")},
"select Col1,Col2,Col4 where Col3='"&D27&"'")

ArrayFormula with sum of previous rows

I have an ArrayFormula to calculate a value for each row, and for each 6th row I want it to calculate the sum of the previous 5 instead.
Example sheet: https://docs.google.com/spreadsheets/d/18g2bOOBqsUgmy3ZXINOl6hcaMXf-uYJv7PGft247FjU/edit?usp=sharing
I have tried several routes, including google script, but keep banging my head against limitations of ArrayFormula.
You need make group by rows
My E.g
Cell A2 (Name groups):
=ArrayFormula(IF(B2:B<>"",FLOOR((ROW(A2:A)-2)/5)+1,""))
Column B (Your Data)
Cell E2 (Result):
=QUERY({QUERY({A2:B},"select Col1,sum(Col2) where Col1>0 group by Col1");
QUERY({A2:B},"select Col1,Col2 where Col1>0")},
"select Col2 where Col1>0 order by Col1,Col2 label Col2 ''")
Function References
Query

Resources