Google Sheets Query And Importrange Equals Cell D2 - google-sheets

I've got two spreadsheets, a primary sheet (that a google form dumps into) and another sheet (aka management sheet) that has shared access to the primary sheet. I'm trying to run the query below to automatically import a serial number based on the hostname in column D of the management sheet.
I can run a simple importrange successfully, so the access permissions are working properly.
=QUERY(IMPORTRANGE("[URLHERE]”, “Form Responses 1!A2:H”), ”Select Col7 where Col5="&$D2))
Any help would be appreciated, thanks in advance!
Jerome

try:
=SINGLE(QUERY({IMPORTRANGE("1pRWLfnYsJhmJFZio_pvny7oO8UCSUxfGhTc78TbwVhw",
"Form Responses 1!A:H")}, "select Col7 where Col5 = '"&D2&"'", )

I figured it out.
=query({IMPORTRANGE("1pRWLfnYsJhmJFZio_pvny7oO8UCSUxfGhTc78TbwVhw", "Form Responses 1!A2:H")}, "Select Col7 where Col5 = '"&D2&"' LIMIT 1",0)
Jerome

Related

How to Combine Data when Columns are Different in Google Sheet

I am trying to have a master file that contains data from 3 separate sheets. Each sheets has the same first 5 columns in order but 3 other columns are in different order in the 3 sheets. How can I combine the data when columns are located differently into one master file?
you can rearrange columns in {} array:
=QUERY({
{QA_Assignments_2021!A2:H};
{QA_Group_2021!A2:F, QA_Group_2021!H2:H, QA_Group_2021!G2:G};
{QA_LOMFCU_2021!A2:H}},
"where Col1 is not null")
or you can do it with multiple queries like:
=QUERY(
{QUERY(QA_Assignments_2021!A2:H, "select A,B,C,D,E,G,H,F");
QUERY(QA_Group_2021!A2:H, "select *");
QUERY(QA_LOMFCU_2021!A2:H, "select A,B,C,H,G,E,F,D")},
"where Col1 is not null")
player0 already provided a great idea of how you will solve your issue. If you are doing it right, it should look like the formula below:
=Query({
Query(QA_Assignments_2021!A2:AB, "select A,B,C,D,E,F,I,N,H");
Query(QA_Group_2021!A2:AB, "select A,B,C,D,E,F,T,L,R");
Query(QA_LOMFCU_2021!A2:AB, "select A,B,C,D,E,F,Y,H,S")
}, "where Col1 is not null")
Output:
Note:
The three A2:AB can be simplified into A2:N, A2:T and A2:Y respectively since you don't need the columns beyond that. But either of the two should work. Adjust the ranges and columns to be queried accordingly if needed.

Importrange from multiple google sheets, issue when any one sheet has no data to import

I am importing data from two different Google sheets and merging them in another sheet. The formula which I used is as below .
=QUERY({
IFERROR(QUERY(
{ IMPORTRANGE("" , "Sheet1!$A$1:$b") },
"SELECT Col1,Col2 WHERE Col2='Total'",
0
)) ;
IFERROR(QUERY(
{ IMPORTRANGE("" , "Sheet1!$a$1:$b") },
"SELECT Col1,Col2 WHERE Col2='Yes'",
0
))
})
In above formula, importrange is giving the result when both sheets have data to import, but if any one sheet has no data to import the data from another sheet is not getting imported. I had figured a solution at below link where we can handle this issue by using dummy column reference, this approach is fine when we have few sheets to import with few columns but when we are importing from many sheets and many column to import the dummy column reference gets too long. Is there any other way to solve this issue.
The easiest way to do this is to use an IFERROR(SEQUENCE(1,n)/0) as your output for when a query of an importrange fails instead of needing to list a bunch of blanks.
The solution for your simple example looks like this where n = 2:
=ARRAYFORMULA(QUERY({IFERROR(QUERY({IMPORTRANGE("1hea986JF3plR_tn7plNRgjWhiGqxOlR8s8yE-Ri6FfU" , "Sheet1!$A$1:$b")}, "SELECT Col1,Col2 WHERE Col2='Total'",0),IFERROR(SEQUENCE(1,2)/0));IFERROR(QUERY({IMPORTRANGE("1IbPpoLLfa-ukoz2WInlgNGSNMNBxBwSx4in52fZCEyE" , "Sheet1!$a$1:$b")},"SELECT Col1,Col2 WHERE Col2='Yes'",0),IFERROR(SEQUENCE(1,2)/0))},"where Col1 is not null"))

Google Sheets import range returning incorrect data

The full google spread sheet system is used for score keeping and is prone to delays when updating, however I have never run into an issue like this were the same basic function is returning two separate results. The problem is repeatable and occurs on more than one spreadsheet.
I have created a test sheet-
https://docs.google.com/spreadsheets/d/1arh0D9ch5MpQjRh_bHjLfLx5S7TAW8R_pgGLf5tovig/
with the code in question; Can anyone help please?
=QUERY(IMPORTRANGE("***","***"),"select Col1 where Col1 <>5 order by Col9 desc")
in your QUERY formula you are selecting cells that are numeric and comparing it to <>5 but take a notice that A2 is not numeric:
that is the reason why 2 2 is not included in your C column
also it looks like that your QUERY formula smashed first cells into one because you did not specify the 3td query parameter. try:
=QUERY(IMPORTRANGE("1pnowvo6YVj-DZAPCaKE2x9vSIbpAAmlwhRMO2OZNlrE","color!A84:M115"),
"select Col1 where Col1 <>5 order by Col9 desc", 0)

Is there a way to link data by names in Google Sheets?

I am using Google Forms and Sheets to create a way of tracking services including time for some of our students. I have the forms linked to a Sheet and am able to pull the "Clock In" data and "Clock Out" data into a single sheet. My issue is: when I go to analyze using pivot tables it pulls the data from the cell of the next row (students do not necessarily clock in/out in the order they arrive). Is there a way I can link the data by name and then order by time?
Any help would be greatly appreciated!
Example Sheet
you can but not in one go because pivot tables are not so advanced. create a new sheet and paste this in A1 cell and then crate your pivot table from this sheet:
={QUERY({Combination!A1:E}, "where Col1 is not null order by Col3, toDate(Col1) , toDate(Col2)", 1),
QUERY({Combination!F1:I}, "where Col1 is not null order by Col3, toDate(Col1) desc, toDate(Col2) desc", 1)}

Import Range from spreadsheet but exclude rows with missing data

I have 2 spreadsheets (sheet1 + sheet2)
Sheet2 Pulls in data from Sheet1 using the IMPORTRANGE function which works fine, except that there are a few rows that have missing information in 1-2 columns and for the purpose of what I am trying to do I need to just remove these rows.
Can anyone point me in the right direction? Not sure if I need to add something to the IMPORTRANGE function or create a new spreadsheet and use a different function or do I have to manually delete these rows?
Cheers
The QUERY function provides this ability. The "IS NOT NULL" argument works with numbers, and "!=" is for Strings (anything that's not just numbers).
=QUERY({IMPORTRANGE("YourKey","SheetName!A:B");
IMPORTRANGE("YourKey,"SheetName!A:B");},
"SELECT Col1, Col2 WHERE Col2 IS NOT NULL")
Or
=QUERY({IMPORTRANGE("YourKey","SheetName!A:B");
IMPORTRANGE("YourKey,"SheetName!A:B");},
"SELECT Col1, Col2 WHERE Col2 != ''")

Resources