How can I query from multiple Google sheets? - google-sheets

I wanted to query data from multiple sheets but couldn't find the correct formula. I used the below formula and it worked fine with querying from one sheet.
=QUERY('2022'!A1:S38, "Select B,H where R='N' and S=TRUE order by H")
Then I used the below formula hoping that I could derive the information from 2 sheets but it didn't work. Appreciate if someone could help me on this
=QUERY({'2022'!A1:S38;'2023'!A1:S38}, "Select B,H where R='N' and S=TRUE order by H")

use Col references:
=QUERY({'2022'!A1:S38; '2023'!A1:S38},
"select Col2,Col8
where Col18='N'
and Col19=TRUE
order by Col8")

Related

How to convert SUMIFS to Array Formula Google Sheets

I have been trying to Convert the SUMIFS formula into Array but its not working in google sheets then i tried to follow online instructions and i am unable to that.
I hope someone can help me to fix the fomrula:
Formula1:
SUMIFS('Employee Leave Setup'!$I:$I,'Employee Leave Setup'!$B:$B,$B2:B,'Employee Leave Setup'!$X:$X,K$1)
Formula2:
=ArrayFormula(if(len(B2:B), iferror(vlookup(B2:B,QUERY({'Employee Leave Setup'!B:X}, "SELECT Col1, COUNT(Col22) Group by Col1 label COUNT(Col22)"",0),2,),0),))")))))
Sheet
Try:
=MAKEARRAY(COUNTA(B2:B),COUNTA(K1:W1),LAMBDA(r,c,SUMIFS('Employee Leave Setup'!I:I,'Employee Leave Setup'!B:B,INDEX(B2:B,r),'Employee Leave Setup'!X:X,INDEX(K1:W1,,c))))
You can also use SUMIF and concatenate the conditions.
=ArrayFormula(IFERROR(1/SUMIF('Employee Leave Setup'!B5:B&'Employee Leave Setup'!X5:X,B2:B&K1:W1,'Employee Leave Setup'!I5:I)^-1))

Import Range Query not importing data

Sorry I know this question has been asked before - I have tried changing my query around but can't seem to get it to work as expected, doesn't look to be anything wrong..
I am simply trying to query data from one large master sheet into a few separate sheets. I am using importrange to get the data from sheet, and a simple select query to filter by one of the columns. If I do a select * I get all the data as expected, but can't use a WHERE clause with any column (I just need 1 of the columns, but I tried with a few different ones).
Appreciate any help!
Query:
=QUERY(IMPORTRANGE("1sNA9u2uQW-XjEKjrVS2a5LtTPCchwSuTkXfjhTJtvPk","Sheet1!B:I"),"select * WHERE 'Rank'='LTC' ")
Columns
Username Rank Time In Service TIS Time In Grade TIG Promotable Awards PLT/SQD
Source sheet: https://docs.google.com/spreadsheets/d/1sNA9u2uQW-XjEKjrVS2a5LtTPCchwSuTkXfjhTJtvPk
Test sheet: https://docs.google.com/spreadsheets/d/1UCucsfE0M4j95d_47iN0LrAhS0luv8wXVMHRVTHJHRQ
As player0 stated, you should refer to the columns by its number, you can select multiple columns and state multiple "where" statements by using Col1,Col2, etc respectively. In this case: Where Col2 = 'LTZ'
try:
=QUERY({IMPORTRANGE("1sNA9u2uQW-XjEKjrVS2a5LtTPCchwSuTkXfjhTJtvPk", "Sheet1!B:I")},
"where Col1='LTC' ", )

Using Countif, Vlookup and Importrange

I'm currently struggling with using the Countif, Vlookup and Importrage formula on Google Sheets...
I need to pull data from the raw data sheet to the data set that I'm using and can't get it right.
Formula that I have is as follows:
=countif(vlookup(A2,IMPORTRANGE("URL","Data!A2:I940"),9,false),"supplier")
I need to look up the date and then get the count for how many "Suppliers" we had on that specific dates..
Anyone having the same issue or is my brain just over worked???
I think a better choice would be to use a query formula instead.
Please follow the logic of this given formula
=QUERY({B1:D12},"select count(Col1)
where Col3=date'"&TEXT(F1,"yyyy-mm-dd")&"' and Col2='"&F2&"'
label count(Col1) '' ")
(Do adjust ranges to your needs)

Extract all partial matches: AGGREGRATE FORMULA TO replicate in GOOGLE SHEET

I need help on replicating below formula into Google sheet. Since google sheet does not support Aggregate, I am having difficulties replicating it into google sheet.
I need a formula which will list out all partial match item based on specific text from data.
Help is much appreciated.
Below is the formula I am using in excel:
=IFERROR(IF(F5>$D$9,"",INDEX($B$5:$B$16,AGGREGATE(15,6,(ROW($B$5:$B$16)-ROW($B$5)+1)/ISNUMBER(SEARCH($D$5,$B$5:$B$16)),F5)))," ")
and below is sample data and result outcome:
use in F2:
=QUERY(A2:A; "select A where A contains '"&C2&"' limit "&C6; 0)
or case insensitive:
=QUERY(A2:A; "select A where lower(A) contains '"&LOWER(C2)&"' limit "&C6; 0)

Display Rows From Another Sheet Based On Range Of Dates

I'll try to explain this as best as I can, I'm not super experienced with spreadsheet formulas so bear with me.
Currently I have 2 Google spreadsheets, one contains a list of all client related tasks. The second spreadsheet is client specific, it has a few sheets such as "Feeder", "Archived Requests", "Monthly Report". The "Archived Requests" sheet lists all the data assigned to a specific client from my first spreadsheet using QUERY IMPORTRANGE:
=Query(IMPORTRANGE("key","spreadsheet-name!A:Z"),"Select Col2, Col3, Col4, Col5 where Col1 contains 'TOSC'",1)
This part works all fine and good.
My "Feeder" sheet lists some =DATE and =EOMONTH formulas which I have made into Named Ranges.
What I'd like to do, ideally, is display all data from the "Archived Requests" sheet on the "Monthly Report" sheet between the named range "ReportMonthStart" and "PriorMonthStart".
Essentially, what I'm hoping to achieve is a dynamic listing of row data that goes back 30 days from the 15th of each month.
I'm not sure if this should/can be done with a Query or a Filter, or any other formula.
Here is the link to my current spreadsheet.
The filter does this nicely:
=filter('Archived Requests'!A2:E, ('Archived Requests'!A2:A >= PriorMonthStart) * ('Archived Requests'!A2:A <= ReportMonthStart))
This returns A-E entries of the rows where A column is between PriorMonthStart and ReportMonthStart. Multiplication of two conditions is logical AND.

Resources