Update a Google spreadsheet with a unique identifier - google-sheets

I want to update a google spreadsheet using a form. Each customer fills out the form with a unique identifier. This same identifier is entered in column A of each row.
I would like the other columns (B, C, ...) to be updated automatically according to the customer number.
Anyone have an idea for a script to use?

Try using an ARRAYFORMULA together with VLOOKUP. You can see the documentation here and here respectively.
For example: =ARRAYFORMULA(VLOOKUP(A1:A,'other_sheet!A1:C,2,0))
This will add each value in A to each value in B like A1+B1, A2+B2, A3+B3, and so on.
If you post the formula you are trying to use, I may be able to adapt it using Arrayformula.

Related

Trying to index match data from a different workbook

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.)

Use Unique in a Filter formula

I have a list of identifiers and a value for each identifier which is filled automatically.
I want to filter the list so I will only get unique identifiers and their respective value.
e.g. "Dana" can appears 3 times but in the filtered table I only want to see the name (and the value) once.
Ideally I'd like to use something like
=filter(a:b,unique(a:a) which obviously doesn't work.
As mentioned, the list updates automatically so a formula that needs to be dragged won't do the trick.
Note: It can be solved by extracting uniques from col A
=unique(A:A)
and then an Arrayformula + vLookup
=arrayformula(if(I1:I>0,vlookup(I1:I,A:B,2,0),""))
but I'm curious to see if it can be solved using Filter for more elegance.
Here's an example (including the solution I mentioned):
https://docs.google.com/spreadsheets/d/1heKdV3U6mdGYkHCIWkeUyqo6AfhgV7ItSmolibH7ecU/edit?usp=sharing
Please use the following
=UNIQUE(A:B)
UPDATE
Following OP's comment/request:
Nice fix! Out of curiosity - is it possible to still use it with the filter function (for example, if I wanted to filter by Col B or add other restrictions) ?
Sure. Try these ones out
=UNIQUE(FILTER(A:B,B:B=333))
OR
=FILTER(UNIQUE(A:B),UNIQUE(B:B)=333)
Reference:
UNIQUE

Formula (Array, etc.) for automatic Google Sheets Indexing using inputs from Google Forms

I'm hoping that someone can help me tweak (or even substitute) a formula that I'm using in Google Sheets to automatically populate columns with information based on inputs from a Google form.
Simply put, I am using the Index function to match the name that is selected from a drop-down menu in the Google Form and arrives in Column E of the Google Sheet receiving the responses with an identical list of names in Column A of 'Sheet 2'. The index formula takes information from 'Sheet 2' relating to that name (e.g. Registration Number, Email Address) and places it in the 'Formresponses 1'sheet alongside the inputs from the Google form (including, of course, the name that appears in Column E'.
I have been using (variations on) the following formula without any issues, but I have to manually drag it down the relevant column in 'Formresponses 1' each time a new entry/name arrives from the Google Form: =index(Sheet2!$B$2:$B,match(E2, Sheet2!$A$2:$A,0),1)
I have successfully used Array Formulas to automatically carry out other functions on data arriving from a Google Form (i.e. adding up individual numbers to arrive at an overall total), but in this case I cannot figure out how to create a formula that will automatically take each new name that arrives in column E and insert it into the relevant indexing formula at that end of that new row.
Any suggestions - or solutions! - would be greatly welcome!
Thanks,
A.
Cheers I'-'I,
I've used I'-'I's response to my original question here as a starting point and, with a bit of research, I've come up with the following working formula:
= ArrayFormula(vlookup(E2:E, Sheet2!A:E, {1,2,3,5},FALSE))
[The curly brackets simply indicate the columns in Sheet 2 from which I want to pull pieces of data relating to each name that is matched up in the 'front end' sheet receiving the responses from the Google Form.] As with my previous problems with array formulas, I found the following website really useful, so full credit has to go to it: benlcollins.com

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.

reference cell via two partial matches on another cell

I need to match two conditions on the cell Name and add the price information into cell price if both condition match. In other words, if Name contains both conditions, get the price. I tried different approaches using QUERY, SEARCH; FIND; VLOOKUP but I got stuck somewhere in the middle. Here's the example sheet (Google Spreadsheet solution preferred over Excel):
https://docs.google.com/spreadsheets/d/1zwG3_5Ctg_IZ1kI04Uee-qIvMrNQ4GmEwySmYcMKLfA/edit?usp=sharing
Maybe important: Both, the Name values as well as the whole reference table get pulled from other files dynamically. So I don't know anything concerning order or length of these columns in advance, not even if there are matches at all.
In addition to previous answer AND given the current set of data (in a Google spreadsheet), in B2 try:
=ArrayFormula(iferror(vlookup(regexreplace(A2:A; "[^A-Z]"; ""); {E2:E&F2:F\G2:G}; 2; 0)))
and see if that works ?
Based on your spreadsheet table:
you can try the following formula:
this formula works in excel not in google spreadsheets
=IFNA(INDEX($G$2:$G$6;MATCH(1;COUNTIFS(A2;"*"&$E$2:$E$100&"*";A2;"*"&$F$2:$F$100&"*");0));"NOT FOUND")
this is an array formula, so press ctrl+shift+enter to calculate the formula.
i think it will do the job.
here is the example file to download

Resources