VLOOKUP to match multiple Columns - google-sheets

I have been trying to match multiple columns then paste the result after matching.
Here is the formula
=ARRAY_CONSTRAIN(ARRAYFORMULA(IFERROR({"Formula";IF(A2:A1000="",, VLOOKUP(A2:A1000&B2:B1000&C2:C1000&D2:D1000&E2:E1000,{Sheet2!A2:A1000&Sheet2!B2:B1000&Sheet2!C2:C1000,Sheet2!D2:D1000,Sheet2!E2:E1000 }, 6, 0) )})), 1000, 1)
Same Data is available in sheet2 but additionally with Column 6 values i want to paste Column 6 values into Sheet1 Column 6 after matching. I have tried to get where i am wrong but could not fetch the problem.
Any help will be appreciated.
Link to Sheet

Assuming the combination of first and last name will be unique you can try
={"HEADER TITLE"; ArrayFormula(IF(LEN(A2:A), VLOOKUP(A2:A&B2:B, {Sheet2!A:A&Sheet2!B:B, Sheet2!F:F}, 2, 0),))}
If you want to match all values in the range A:E, please try
={"HEADER TITLE"; ArrayFormula(IF(LEN(A2:A), VLOOKUP(A2:A&B2:B&C2:C&D2:D&E2:E, {Sheet2!A:A&Sheet2!B:B&Sheet2!C:C&Sheet2!D:D&Sheet2!E:E, Sheet2!F:F}, 2, 0),))}

Related

Incrementing a column in a group using an Array Formula in Google Sheets

I am having difficulties trying to get an array formula to increment a column and restart the increment whenever a condition has been met.
Here is an example of what I am trying to achieve, but this has been done manually. It would be great if this could work in an array formula as we'll be adding more rows and would rather not drag the formula down.
[Update based on feedback of the original post]
Column A contains a list of names and teams.
Names are already organised into teams.
The aim is to go through each row and provide a name with an index starting from 1.
Then when a new team is found in column A the index starts again from 0.
The aim is to make this an Array Formula to avoid having to manually re-add the formula when more rows are added.
Link to sheet:
https://docs.google.com/spreadsheets/d/1K00LRFNrN99fFXQO1tzp8jjZeCuTxwENXNGuLj0K0ao/edit?usp=sharing
Example
Any thoughts or advice on this would be greatly appreciated.
I've added a new sheet ("Erik Help") to your sample spreadsheet. It contains the following formula in B1:
=ArrayFormula({"ID Index"; IF(A2:A="",, IF( REGEXMATCH(LOWER(A2:A),"team"), 0, ROW(A2:A) - VLOOKUP(ROW(A2:A), FILTER(ROW(A2:A), REGEXMATCH(LOWER(A2:A),"team")), 1, TRUE)))})
The header text is included in the formula. You can change it as you like.
If a cell in A2:A is blank, the corresponding cell in B2:B will be as well.
If REGEXMATCH finds a match with "team" in the lowercase rendering of a cell in A2:A, 0 will be returned for the corresponding cell in B2:B.
Otherwise, VLOOKUP will lookup each remaining row number in a FILTERed array containing only those row numbers where the word "team" appears. (In your sample set, that will be 2, 8, 12). When the exact match is not found (which it will not be for any remaining row), TRUE tells VLOOKUP that, since the search array is in strict ascending order, we want it to "bump back" to the most recent value found. In each case, the returned row number of the most recent row containg "team" is then subtracted from the actual row number to produce the recurring incremental numbering 1, 2, 3, etc.
try:
=INDEX(IFNA(1*IF(REGEXMATCH(A2:A, "Day"), 0, REGEXEXTRACT(A2:A, "(\d+)"))))

How to get data from concatenated strings in one cell to another table in Google Sheets?

for my use case, I have a Google survey that is connected to a main Google Sheet.
The survey has a 2 questions: 1. Name, 2. Multiple Choice from 1-31 (days of a month).
My survey results come into a by Google survey/Forms automatically generated table in Google Sheets with 2 columns: 'Name', and 'Which days?'. The 'Which Days?' column is has cells with a concatenated list of strings (e.g. '1, 3, 6, 8, 11').
The main Google Sheet has following structure: The first column is 'Name' that just imports the name from the Typeform Sheet (this works fine).
The remaining columns represent the days of the month (so up to 31 columns from 1-31).
Under each column, there are checkboxes.
The idea is that the checkboxes will automatically check according to the results from the Typeform (instead of checkboxes, we could also use colored cells if that is easier).
The problem:
How can I automatically get the data from the concatenated cell 'Which Days?' (e.g. '1, 3, 6, 8, 11') to the main Google Sheet (so that columns '1', '3', ..., '11' are checked/colored)?
Thank you!
You can use this formula on cell B2 of your main sheet (assume Sheet1 is your survey sheet and Sheet2 is your main sheet):
=IF(iferror(match(CELL("address",B2),ARRAYFORMULA(ADDRESS(ROW(B2),1+split(Sheet1!$B2,","))),0),0),TRUE,FALSE)
Then drag right and down to the end of the table.
Sample:
Explanation:
SPLIT creates an array of numbers based on your input delimited by commas.
ADDRESS creates a string of cell references. ARRAYFORMULA extends this to an array.
MATCH returns a valid value if the CELL reference of the cell position exists on the other table, else it will return error.
IF and IFERROR will return true or false depending on the value of MATCH.
use:
=ARRAYFORMULA(REGEXMATCH(COLUMN(B:K)-1&"",
"^"&SUBSTITUTE(SUBSTITUTE(IFNA(VLOOKUP(A10:A12, A1:B3, 2, 0)), " ", ), ",", "$|^")&"$"))

Autofill numbers based on column

This may seem extremely elementary, however, I haven't been able to figure it out. I am wanting to be able to autofill a number series up to 6.
For example, the column would go from 1, 2, 3, 4, 5, 6 down each row, and then start over after 6. The columns in A2 would have the item and the columns in f are the position of the item in the gallery (crm requires 6 for each). Basically, it would repeat itself based on column A2. Is there a formula or an array type formula for this or something like it?
try:
=ARRAYFORMULA(IF(A2:A="",,FLATTEN(SPLIT(QUERY(REPT(" "&
QUERY(SEQUENCE(6, 1),,9^9), ROUNDUP(COUNTA(A2:A)/6)),,9^9), " "))))
You can use this formula in cell F2.
=ARRAYFORMULA(MOD(ROW(A2:A)-2,6)+1)
This would get the row number from A2, subtract by 2, divide by 6 and get the remainder, then add by 1.
Here is a row-agnostic version based on Carlos M's suggestion:
=ArrayFormula(IF(A2:A="",,MOD(SEQUENCE(ROWS(A:A)-ROW(),1,0),6)+1))
By "row agnostic," I mean that if the parallel range were moved to be A3:A or A5:A, etc., that is the only part of the formula that would need to be adjusted; the rest would accommodate without change.

Google Script for Google Spreadsheet that, given two specific Sheet names, updates the dates from Sheet 2 to Sheet 1

I'm studying how to do that but I'm really just beginning and I find it very difficult to put in the code.
The situation:
I have 2 Sheets:
In Sheet 1 i have 8 columns named "ID" "Date1" "Date2" "Date3" "Date4" "Date5" "Date6" "Date7" on the first row. ID is a univocal String, dates are, well, dates.
In Sheet 2 I have multiple columns, that could be different and not in the same order, but among them, there will be the same "ID" "Date1" "Date2" "Date3" "Date4" "Date5" "Date6" "Date7" on the first row
What do I need?
The script should look for the first item in the column "ID" in Sheet 1, and search it in the column "ID" in Sheet 2. If it finds it, it should copy the dates values in the same row from Sheet 2 to Sheet 1.
Could you help me?
are you sure that you need a script for this?
because it can be easily achieved with just a simple formula called VLOOKUP
=ARRAYFORMULA(IFERROR(VLOOKUP(D:D, Sheet1!A:B, 2, 0)))

Match two columns on different sheets and post back some columns to third sheet using formula

Column A of Elements sheet has Ids. Column B of Connections sheet has Ids
I need to match on these two columns and post back columns 2, 4, 6 of the Elements sheet to a third sheet
I am trying this formula but I am unable to get it to work, there is no error but nothing is returned
=ArrayFormula(iferror(vlookup(Elements!A1:A893, Connections!B1:B893, {2,4,6}, 0)))
Thanks
The IFERROR will be stopping any error messages being shown. One of these alternative methods might work:
=query(Elements!A:F, "select B,D,F where A matches '"&TEXTJOIN("|",1,Connections!B1:B893)&"'")
=filter({Elements!B:B,Elements!D:D,Elements!F:F},match(Elements!A:A,Connections!B1:B893,0))

Resources