I'm trying to use Google Spreadsheets in conjunction with a Google form to 'collect' data, use the collected data to locate associated data in a source spreadsheet, and then import that targeted data into a separate target spreadsheet. I've done some research in Google Groups and 'think' I have the basic function, but I'm missing the 'if/then' portion and the syntax is off.
RED cell in 'target' will be used to locate the appropriate row in 'source'.
Green cell in 'target' will be used to locate the appropriate column in 'source'.
What I have so far...
=QUERY(importRange("[key]", "Sheet1!A1:C5"), "select Col1, Col2, Col3 where Col2='data1'", 1)
The "select Col1, Col2, Col3 where Col2='data1'", 1) portion of the function is the part I'm stuck on.
First, I want to locate a row in the source spreadsheet based on cell data in the target spreadsheet. For example, where Col2='B2'", 1)
Second, I want to pull specific data from the source spreadsheet based on a 'if statement'
For example, if col3=2nd then copy col4, col5 if col3=3rd then copy col6, col7. **I know this section is completely off.
Any suggestion?
Thanks everyone!
Todd
High School Teacher # Grossmont High School
=VLOOKUP($B2,Sheet2!$A$1:$G$7,MATCH("Teacher"&LEFT($C2,1),Sheet2!$A1:$G1,0)+COLUMN()-4,0) in D2 and copied into E2 of Target sheet seems to work in both Excel and Google Doc spreadsheet, though it is not a script.
Related
I've 3 or more Google sheets. Each sheet covers different aspects of employee info. These sheets would get new entries added every now and then. All the sheets have ID column.
The new sheet has UNION of all fields from different sheets joined by a common field present in every sheet, e.g. email id.
For example:
Source 1:
Source 2:
Expected new sheet with the integrated data joined by email id is:
Ideally, the integrated sheet should not have the repetition of join key, i.e. Email.
I want this integrated sheet to be automatically updated with new rows as and when new data comes in all the sheets. Ideally, this should happen when data in all the source sheets are complete for a given ID.
What is the best way to achieve this?
use arrays {} like:
=UNIQUE(QUERY({Sheet1!A2:B; Sheet2!A2:B; Sheet3!A2:B};
"where Col1 is not null"))
update 1:
=UNIQUE(QUERY({
IMPORTRANGE("url_of_spreadsheet_here"; "Sheet1!A2:B");
IMPORTRANGE("url_of_spreadsheet_here"; "Sheet2!A2:B");
IMPORTRANGE("url_of_spreadsheet_here"; "Sheet3!A2:B")};
"where Col1 is not null"))
side note: each importrange formula needs to be run as standalone to connect your sheets by allowing access - only then you can use above formula
update 2:
if columns are mixed you can "correct" them like:
=UNIQUE(QUERY({
QUERY(IMPORTRANGE("url_of_spreadsheet_here"; "Sheet1!A2:C"); "select Col1,Col2,Col3");
QUERY(IMPORTRANGE("url_of_spreadsheet_here"; "Sheet2!A2:C"); "select Col3,Col2,Col1");
QUERY(IMPORTRANGE("url_of_spreadsheet_here"; "Sheet3!A2:C"); "select Col2,Col3,Col1")};
"where Col1 is not null"))
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"))
I am not sure why this functionality stopped working, but I am sure it has to do with inconsistent back end data or how the query condition "CONTAINS" needs to be changed. The IMPORTRANGE portion works just fine, but will not always pull data into the front end sheet. The query portion looks like this
SELECT Col3, Col2, Col1 WHERE Col2 CONTAINS "&'Job Number'!A1&" ORDER BY Col3 ASC,1
Column 2 contains job numbers that are xxxxx with another 3 digit code appended to end of it. It will only populate temporarily if I manually go into the sheet and edit the IMPORTRANGE range values. If I close the spreadsheet and open it again it will not populate. Does the data in Column 2 need to be a consistent datatype throughout the column or it will break the query?
Unfortunately we do not have a test sheet, so we can not know what the expected results would be.
Nevertheless, your formula syntax is not correct.
The correct syntax would be:
SELECT Col3, Col2, Col1 WHERE Col2 CONTAINS '"&"JOB"&A1&"' ORDER BY Col3 ASC,1
Please notice the syntax '"&"JOB"&A1&"'
(If you still have issues please share a test sheet and let us know.)
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)}
I have multiple google sheets (45 of them, all dynamic, its content will keep on changing) and I want to combine data of all of them into a single file. I was hoping to use some importrange or QUERY function so that moment one / any file is updated, the changes reflect automatically on the combined sheet.
Example book 1 :
https://docs.google.com/spreadsheets/d/1sOkV9BT8ptndE0xcN2MUi4tTZ5p-aZxuLY_u29Y6nBI/edit?usp=sharing
Example book 2 :
https://docs.google.com/spreadsheets/d/1jZml9oVI2Flma407AB4ndl_ZIsQ_5I8zhkzvbL_EO_g/edit?usp=sharing
Example combined book :
https://docs.google.com/spreadsheets/d/1LkiIY1aUmwaouR7f4KhaGs6MV365KY7DYUPMiTzxjvc/edit?usp=sharing
first you need to connect them by pasting each IMPORTRANGE formula in some cell to get #REF! error
then hover over that #REF! error with your cursor and a secret magic button will popup
click on it to allow access
then you can stack up all import ranges and wrap them in a query:
=QUERY(
{IMPORTRANGE("ID1-or-URL1", "Sheet1!A1:A");
IMPORTRANGE("ID2-or-URL2", "Sheet1!A1:A");
IMPORTRANGE("ID3-or-URL3", "Sheet1!A1:A");
IMPORTRANGE("ID4-or-URL4", "Sheet1!A1:A")},
"where Col1 is not null"), 0)
update:
={ IMPORTRANGE("1sOkV9BT8ptndE0xcN2MUi4tTZ5p-aZxuLY_u29Y6nBI", "Sheet1!A1:N2");
QUERY({IMPORTRANGE("1sOkV9BT8ptndE0xcN2MUi4tTZ5p-aZxuLY_u29Y6nBI", "Sheet1!A3:N" );
IMPORTRANGE("19SFnJab9xVW2SenK-8IuG2cQRT2exJeyqARjTdDE_R8", "Sheet1!A3:N" )},
"where Col1 is not null", 0)}