Trying to index match data from a different workbook - google-sheets

My colleague collects data in Google Sheet A. I want to reference and index-match some of that into my sheet B where I track the progress of projects. I've tried two different ways of doing it, and neither of them work for me.
Here are the two ways I tried:
I created a new tab in sheet B. Then I used importrange to sync with the data from sheet A. Then I used index match to reference the data from the importrange in the same sheet. Indexmatch did not work with the importrange data. Only once I copied and pasted it as values, did the data come over, but that of course broke the live synced importrange.
I tried to do the indexmatch and importrange at the same time using this formula from this forum:
=INDEX(IMPORTRANGE("SheetA",Tab"!A4:H26"),MATCH($Cell,IMPORTRANGE("SheetA",Tab"!A4:A26"),0))
But that just gave me an error.
Any other ideas on how to approach this?

use vlookup:
=VLOOKUP(A1; 'Sheet A'!A:H; 2; 0)

Maybe because it's just schematic, but have you used the quotation marks this way? --> Tab"!A4:H26"
You should use them like this --> "Tab!A4:H26"
And when you write "SheetA" you're writing the Spreadsheet Id, right??
And you should add another comma before the last parenthesis and tell which column you want to grab the final data from (1 for Column A, 2 for column B, etc.)

Related

IMPORTRANGE in Google Sheets preserving the structure of the destination sheet

Suppose that we have the following Google Sheet (called File_1):
And we import all the columns (A to C) via IMPORTRANGE("https://docs.google.com/spreadsheets/...", "Sheet1!A:C") into another sheet (called File_2), which also contains an additional column New_col with some data in it:
Now, suppose that the source sheet changes like this, i.e., a new row is added in-between the existing rows:
The destination sheet will become like this, in essence keeping Column D in its previous state and 'breaking' the relation of the 'test' value in cell D2 with the A1-B1-C1 row.
What I would like to have instead is the following destination sheet:
Is there a way to do that from within Google Sheets?
You are describing how formula results get misaligned with manually entered data. There is no turn-key solution to work around the issue. Lance has given a thorough treatment of the row misalignment issue and how it can be dealt with in some cases.

Syncing a cell from an outside sheet to multiple rows in the master sheet with IMPORTRANGE, SPLIT, TRANSPOSE

I am having issues with syncing some data from an outside spreadsheet to a master spreadsheet. The problem lies in the fact that there are multiple strings in each cell of the column I wish to sync. I have tried to solve the problem by using IMPORTRANGE to get the data from the I column (starting at I2 onwards), then splitting the strings and finally transposing them to get them into rows, which works well for the master sheet. I have written it like so:
={TRANSPOSE(SPLIT(IMPORTRANGE("spreadsheet_url","sheet_name!I2:I"),","))}
The problem is in the fact that this formula only works for the first cell (I2), despite the fact that I have specified the entire I column. It gets the correct range of data, but when I use SPLIT on it, it only takes the first one into account.
What am I missing? Is there a way to include a new row as a delimiter also in the SPLIT function and in which way?
Thanks a lot.
try:
=ARRAYFORMULA({TRANSPOSE(SPLIT(IMPORTRANGE("spreadsheet_url","sheet_name!I2:I"),","))})

check for partially filled rows and delete the rows that don't have data in them

I have been working on a google sheet(sheet A) where the data comes from another sheet(sheet B) through importrange. In sheet A, column A contains all the urls, col C is the keywords and col F SEO keywords. I want to implement a function or an app script where for every url in column A, if the data is present in either column C or col F, that row should stay and if for url in column A, the data is col C and F is not present then the row should be deleted and the row below should move up. I am not sure how this should work. Can anyone please help me with the function or app script to be used for the same?
I am not sure I am understanding your question.
So there is an empty B column between A and C column? If so put this in B2 =if(sum(len(C4)+len(F4))>0,A4,"") It'll see if both C&F are empty and if so return a value of blank instead of the URL. You can then just copy-paste values only that over into Column A and you're set right?
From my understanding you want to keep combinations A,C - A,F - A,F,C & omit rows where it is just A as the only value?
If so this should get it done pretty easily. Are you doing this on like 10k+ row sheets?
You will not be able to move around rows with data that was imported with IMPORTRANGE in SheetA.
What you could do is write an Apps Script code to move around the source data in the source sheet since IMPORTRANGE gives you a live overview of the data in the source sheet. This might be the "cleanest" solution. In the source sheet you could have an onEdit trigger sorting your rows so that rows with empty columns are at the bottom. Then you can use IMPORTRANGE to import only the rows where all three columns have the data you want. (Extra careful with using IMPORTRANGE in apps script please, especially when counting rows afterwards due to lag)
Another option would be to just copy the values with a trigger instead of using IMPORTRANGE. This wouldn't be "as live as IMPORTRANGE" though but it would be easier to use the data.
If I understand you correctly, you are importing some data via IMPORTRANGE and you want to remove the imported rows in which columns C and F are empty.
If that's the case, you could use QUERY to filter out the undesired rows in the formula itself, so that they are not imported:
=QUERY(IMPORTRANGE("spreadsheet_url", "sheet_name!range"),"SELECT * WHERE (Col3<>'' or Col6<>'')")
Note:
If you wanted to use a script, the source data should not come from a formula (in that case, you should copy the imported data somewhere else and work with the copied data, which would not depend on the formula).

I need to compare values between two sheets to find matching items

I need to compare two different sheets to find matching values between them.
In the first sheet, I have a list of order numbers and in the second one, I have a list that needs dispatching. Therefore, without scrolling through the sheet manually for the 1000+, I'd like to use a formula or conditional formatting in order to flag the values that are the same (or all of the different values) so I can simply copy and paste this into another sheet.
I have shared a link to a google sheet below if someone could help with this that would be very much appreciated.
Edit: The second sheet (on the google document) is the list of all orders and the first are the ones to be dispatched. I need to know which one's from the second sheet are missing from the first.
https://docs.google.com/spreadsheets/d/18vSBu9GzxK1UMCE2RrDyNSH6yi-FzTvuABsVw9r172Y/edit?usp=sharing
In second sheet in column B you could do:
=COUNTIF(Sheet1!A:A,A2)
IF the formula returns 0, it means that id number is not in your first sheet.

ARRAYFORMULA with IMPORTRANGE

In column B are listed IDs of Google Sheets. In column C are listed cells, from which I want to import data.
Screenshot of the table
In column D is shown the result of using IMPORTRANGE() by simply dragging it. e.g. for D1 it looks like:
=IMPORTRANGE(B1;C1)
for D2:
=IMPORTRANGE(B2;C2)
and so on.
In column E I want to display the same result but using ARRAYFORMULA that looks like:
=ARRAYFORMULA(IMPORTRANGE(B2:B4,C2:C4))
but the function displays only the data from the first spreadsheet.
People complain about this permissions issue a lot, but it's not hard to solve. What I do is have a sheet which I name "Splash sheet" into which I paste the URLs of the documents I wish to link. To its right is a column headed "permit to connect" which contains IMPORTRANGE formulas importing a single cell from each sheet -- usually a cell containing a confirmation code, number or document name -- on a sheet also named "Splash Sheet." For example,
=IF(B3="enter URL",,CONCATENATE(IMPORTRANGE(B3,"Splash sheet!A1")," ",IMPORTRANGE(B3,"Splash sheet!B1")))
So, when you first connect a spreadsheet via its URL, you get those messages telling you you need to connect, you click the Permit Access, the confirmation code/number/document name appears in the second column, and voilá, your sheets are connected forevermore! Now all your other IMPORTRANGEs referencing that URL will work, and you can use IMPORTRANGE formulas that reference the URL-containing cells on the "splash sheet."
As for the OP's original question, I came here seeking an answer to the same problem, and after more research have realized that we are attempting the impossible here. No way to do this an ARRAYFORMULA. No way around writing formulas that reference every single cell a document's URL may go into.
Problem is you can't make arrays of arrays in spreadsheets; that would involve multiple dimensions, and the medium is inherently two-dimensional. This is what people use databases for.
ARRAYFORMULA doesn't work when importing data (I think it relates to permissions). You could use something like this, =IFERROR(IMPORTRANGE(B5:B7;C5:C7)) and pre-fill the column first, but still there would be the permissions issue. Each new imported sheet needs it's permissions granted by a user.
TLDR: If I understand your intention correctly when you say you would like to see
=ARRAYFORMULA(IMPORTRANGE(B2:B4,C2:C4)), I believe you can make that
happen using the following.
=ARRAYFORMULA(IMPORTRANGE(
INDIRECT(ADDRESS(ROW(B2:B4), COLUMN(B2:B4)),
INDIRECT(ADDRESS(ROW(C2:C4), COLUMN(C2:C4))
)
Breakdown
Use IMPORTRANGE with INDIRECT to create ranges inside ARRAYFORMULA
Call INDIRECT with the ADDRESS function
Call ADDRESS with the ROW and COLUMN functions since they take ranges via ARRAYFORMULA
using IMPORTRANGE with INDIRECT
IMPORTRANGE's two parameters are the spreadsheet url stored in B2:B4 for this example and the range (e.g. sheet!A1:B2) stored in C2:C4.
Since IMPORTRANGE doesn't take a range reference directly as you mentioned, you'll need to build it for each row with ARRAYFORMULA using the INDIRECT function.
INDIRECT can be used to compose a cell reference using A1 notation, for instance
=IMPORTRANGE(INDIRECT("B" & 2), INDIRECT("C" & 2))
will produce the same result as
=IMPORTRANGE(B2, C2)
Since this produces the same result, we now just have to find a way to make INDIRECT work with ARRAYFORMULA
Use ADDRESS to build the parameters for INDIRECT
Next you want to use ADDRESS to build the A1 reference for INDIRECT. For the current purposes, ADDRESS takes a numerical value for row and column as parameters
=INDIRECT(ADDRESS(2,2))
will produce the same result as
=INDIRECT("B" & 2)
Since these two are interchangeable, now we just need to find a way to get the numerical row and column values out of ARRAYFORMULA.
Call ADDRESS using the ROW and COLUMN functions
From there, you can get the row and column indexes from standard A1 notation using the ROW and COLUMN functions. While this may seem like we're pointlessly going in circles, the difference now is that ROW and COLUMN perform as expected with the ranges provided by ARRAYFORMULA. So given that ADDRESS will return $B$2 using using either method below
=ADDRESS(2,2)
or
=ADDRESS(ROW(B2),COLUMN(B2))
we now know that
=ARRAYFORMULA(ADDRESS(ROW(B2:B4),COLUMN(B2:B4)))
will produce the following array of addresses
{ $B$2; $B$3; $B$4 }
Final Assembly
So when we put this all together, we get
=ARRAYFORMULA(IMPORTRANGE(
INDIRECT(ADDRESS(ROW(B2:B4), COLUMN(B2:B4)),
INDIRECT(ADDRESS(ROW(C2:C4), COLUMN(C2:C4))
)
where INDIRECT(ADDRESS(ROW(B2:B4), COLUMN(B2:B4)) is more or less interchangeable with what you might expect from B2:B4 inside ARRAYFORMULA and represents the url parameter
and INDIRECT(ADDRESS(ROW(C2:C4), COLUMN(C2:C4)) is roughly interchangeable with what you might expect from C2:C4 inside ARRAYFORMULA and represents the range parameter.
Suggestions on organization
I recommend using the indentation (Alt +Enter to create a new line ) above along with your indentation of choice to keep it easier to read. In the end it's just a bit more syntactic sugar and if spaces are used well it shouldn't be much harder to understand and make changes to 6 months later.
RE: Permissions - as mentioned by Atiq Zabinski, just placing a simple
IMPORTRANGE("http:/xxxx", "A1") somewhere on the sheet will provide a
means to know if the sheet is connected or not and the error message
should give you a context menu for connecting the sheet. You'll might
want to stay away from error handling in these scenarios as it will
slow down the process of connecting the sheets.

Resources