Vlookup on partial match - google-sheets

Sample Sheet: https://docs.google.com/spreadsheets/d/16HUbIpN9MfTh5msRl54wMCRddTdKUyST-2XqNsnaPxs/edit?usp=sharing
I need to vlookup on a partial match in the search key. In the attached speed sheet, the search key in column A. If the search key in column A contains the lookup value in column F, the value in column G should be returned in column B.
I would prefer to do it with an array formula because my actual sheet is huge. Your help will be greatly appreciated!

In B2 try
=ArrayFormula(if(len(A2:A), iferror(vlookup(regexextract(A2:A, textjoin("|", 1, F2:F)), F:G, 2, 0)),))
and see if that works?
Regexextract 'extracts' the part of the search key (column A) that matches the vlookup value (column F).
Then, the extracted part is used in Vlookup() to retrieve the value (column G).

Related

Arrayformula with Vlookup matching Data in range

I am trying to use an ArrayFormula along with Vlookup with a range to match the data from another Worksheet. In my demo, the source sheet with Col B with orange and which is Col A is Stack but the destination sheet is not matching where orange exists. I can't understand where is my fault.
I have tried but it's wrong pulled.
=ARRAYFORMULA(VLOOKUP(B:B,IMPORTRANGE("13UCvlMfCse9A_fyVOPlQiwL6JADKZ3O2kMjUfznI-q0", "Source!A:B")},1))
Worksheet demo
I am expecting in the destination sheet that Col A matches Col B.
When using VLOOKUP, the first column of the range must be the search column. And you shouldn't omit the last parameter if you are looking for an exact match.
=ARRAYFORMULA(IFNA(VLOOKUP(B:B,QUERY(TO_TEXT(IMPORTRANGE("13UCvlMfCse9A_fyVOPlQiwL6JADKZ3O2kMjUfznI-q0", "Source!A:B")),"SELECT Col2, Col1"),2,0)))
update
=ARRAYFORMULA(IFNA(VLOOKUP(B:B,MAP({2,1},LAMBDA(col,INDEX(IMPORTRANGE("13UCvlMfCse9A_fyVOPlQiwL6JADKZ3O2kMjUfznI-q0", "Source!A:B"),,col))),2,0)))
With dynamic array formula MAP(), try-
=MAP(B1:INDEX(B1:B,COUNTA(B1:B)),LAMBDA(x,IFERROR(QUERY(INDEX(TO_TEXT(IMPORTRANGE("13UCvlMfCse9A_fyVOPlQiwL6JADKZ3O2kMjUfznI-q0", "Source!A:B"))),"select Col1 where Col2='" & x & "'"),"")))

VLookup Displaying Duplicate Values - Google Sheets

I've created a lookup formula to take values from column E, match them with values in column A, and assign the corresponding value found in column C and populate it in column F.
I've checked for duplicates in E and A, but I'm still seeing duplicates in F. It's not because there isn't a match, I've checked that as well.
My formula is:
=LOOKUP(E2, $A$2:$A$121, $C$2:$C$121)
Here is a simplified version of the spreadsheet: https://docs.google.com/spreadsheets/d/1A-S0nHFIUGycaDo7KDPAzWBwRZQmfxkjaMivwGfBh-8/edit?usp=sharing
delete everything in F column and use in F2:
=INDEX(IFNA(VLOOKUP(E2:E, A:C, 3, 0)))

How to add and highlight rows on input of particular column in Google Sheet

In the attached google sheet.
Google Sheet - https://docs.google.com/spreadsheets/d/1KxqaI-GYWur0Knt_bShI0GURucqU_cawu_sCoG_8Xlc/edit?usp=sharing
I need to execute the following two operations on input.
Add same number of rows against which ID if any user put the value as 1 in column K.
For Example, If I input 1 in column K for ID = ID_3 which has 5 rows, I want to append that five rows below where the last instance of ID_3 and in appended rows all the values should be the same as ID_3 except column C which will now be ID_3_Append, column K and O which should be blank for appended rows.
If someone input value as 1 in column M, We need to check for which ID it belongs and look for that id in column E, F, and G and highlight rows with red color if ID against which user has provided input as 1 is available in column E, F, and G.
If someone adds value as 1 in change type, I need to update the column B to I in the Test_1 sheet from Put_list but want to keep the Mark Status for common ID (if it has any Mark Status) between earlier Test_1andPut_list` unchanged. Also, we need to highlight the dependent rows accordingly.
Once we update column B to I we need to change the Name from 'Call' to 'Put'.
use:
=ARRAYFORMULA(QUERY({QUERY({Test_1!A:O;
IFERROR(IF(IFNA(VLOOKUP(Test_1!C2:C, SORT({Test_1!C2:C, Test_1!K2:K}, 2, 0), 2, 0))=1,
{Test_1!A2:A, Test_1!B2:B, Test_1!C2:C&"_Append", Test_1!D2:J, Test_1!X2:X*0,
Test_1!L2:L, Test_1!X2:Y*0, Test_1!O2:O},
{"","","","","","","","","","","","","","",""}),
{"","","","","","","","","","","","","","",""})},
"where Col1 is not null and not Col3 matches '"&
TEXTJOIN("|", 1, "×", UNIQUE(IF(IFNA(VLOOKUP(Test_1!C2:C,
SORT({Test_1!C2:C, Test_1!N2:N}, 2, 0), 2, 0))=1, Test_1!C2:C, )))&"' order by Col3", 1);
IF(LEN(TEXTJOIN("|", 1,
UNIQUE(IF(IFNA(VLOOKUP(Test_1!C2:C, SORT({Test_1!C2:C, Test_1!N2:N}, 2, 0), 2, 0))=1, Test_1!C2:C, ))))>0,
QUERY({IF(Put_list!A2:A="",,IFERROR(Put_list!A2:A*1, "Put")), Put_list!A2:H,
IFNA(VLOOKUP(Put_list!B2:B&"♦"&COUNTIFS(Put_list!B2:B, Put_list!B2:B, ROW(Put_list!B2:B), "<="&ROW(Put_list!B2:B)),
{Test_1!C2:C&"♦"&COUNTIFS(Test_1!C2:C, Test_1!C2:C, ROW(Test_1!C2:C), "<="&ROW(Test_1!C2:C)), Test_1!J2:O}, {2,3,4,5,6,7}, 0))},
"where Col3 matches '"&TEXTJOIN("|", 1,
UNIQUE(IF(IFNA(VLOOKUP(Test_1!C2:C, SORT({Test_1!C2:C, Test_1!N2:N}, 2, 0), 2, 0))=1, Test_1!C2:C, )),
UNIQUE(IF(IFNA(VLOOKUP(Test_1!C2:C, SORT({Test_1!C2:C, Test_1!N2:N}, 2, 0), 2, 0))=1, Test_1!C2:C&".+", )))&"'"),
{"","","","","","","","","","","","","","",""})}, "where Col1 is not null order by Col3", 1))
transcript:
we start with array of {C, K} columns that we sort based on K column so if K column contains 1 then it will be moved up
this is convinient for VLOOKUP coz it will always look for 1st unique value eg. exactly wat we need if our array is sorted
so we vlookup C values to match our sorted array and return column K for all same IDs 2 stands for 2nd column from sorted array and 0 stands for "exact match"
if no match is found vlookup will output #N/A error so we wrap it into IFNA - then if no match is found vlookup will output empty rows
then we put this into IF statement... if our vlookup outputs 1, we output our columns (again in {array} form
if our vlookup outputs 0 then we output array of 15 empty cells in a row {"","","", .....} this is because we use arrays {} and all ranges in arrays needs to be of same size
our table has 15 columns so if some error would happen the we would get error in one single cell aganist our 15 columns
this way we avoid "array_literal error" having {15 columns; 15 cells in a row which is also 15 columns}
; semicolon puts these two arrays/ranges under each other while , comma will put then next to each other
so if vlookup results in 1 then we assemble our array with ranges... A, B columns are same then we append to C column the phrase "_Append" with &
D:J columns are same... then we force column of zeros by multipling random empty column (X) with 0 etc.
then again we use {"","","", ....} within IFERROR to deal with any possible error at this point
next we put all written above under our whole range Test_1!A:O and we wrap it into QUERY where we state to filter out all empty rows where Col1 is empty and 2nd condition of our query states
that Col3 of our array cant match our regex pattern which we assemble with TEXTJOIN formula
| stands for "or" in regex. 1 in textjoin means "all non empty cells". then we use × (unique symbol) in case textjoin would output empty cell on its own resulting in some error somewhere
again we perform same vlookup, same ifna and same IF but now we output only C column and we are interested only into UNIQUE values
then within the query we sort / order by Col3 our table and 1 at the end stands for "header rows"
This may answer the second part of your question.
Select the range of rows you want the red conditional formatting on, for example A2:A12 in your sample sheet.
Select Format - Conditional Formatting, verify the range, and apply a custom formula, as follows:
=OR(
IF($E2<>"NA",IFERROR(MATCH($E2,FILTER($C$1:$C$12,$M$1:$M$12=1),0)),0),
IF($F2<>"NA",IFERROR(MATCH($F2,FILTER($C$1:$C$12,$M$1:$M$12=1),0)),0),
IF($G2<>"NA",IFERROR(MATCH($G2,FILTER($C$1:$C$12,$M$1:$M$12=1),0)),0))
The FILTER pulls which IDs have a "1" in the update column, ColM.
MATCH looks to see if the ID in the Dependency column is in that filtered list.
The IFERROR sets the result to zero if no match.
And the initial IF, filters out the NA values in the Dependency column.
This logic is replicated for each Dependency column, so three IFs.
And the whole thing is wrapped in an OR function, so if any of the Dependency columns have a matching ID, the whole row is flagged for red.
I've applied this in a tab added to your sheet, Test_1-GK.
Let me know if this helps.
I'm afraid I didn't understand the first part of your question. I got confused with this bit:
I want to append that five rows below where the last instance of ID_3 and in appended rows all the values should be same as ID_3 except column C which will be now be ID_3_Append, column K and O which should be blank for appended rows.

ArrayFormula, SumProduct and Google Sheets returning only 1 value

I have two sheets. I'm using SUMPRODUCT to sum a column based on a matching string.
=SUMPRODUCT(--(skus_campaign!A:A=A2),skus_campaign!D:D)))
This works exactly as expected, if I drag the formula to the rows below.
If I attach ARRAYFORMULA and and IF test to see if there's a blank value, it won't work.
=ARRAYFORMULA(IF(ISBLANK(A2:A), " ", SUMPRODUCT(--(skus_campaign!A:A=A2),skus_campaign!D:D)))
Am I missing something here? Is there an easier way to accomplish this while still using ARRAYFORMULA to grow and shrink the column based on the values in column A?
EDIT: Here's the link to the example Google Sheet. Column "D" under the "Data" sheet is the issue.
Try in E1
={"COGS"; ArrayFormula(if(len(A2:A), vlookup(A2:A, query(skus!A:D, "Select A, sum(D) where A <>'' group by A"), 2, 0),))}
and see if that produces the desired result. If it does, clear all values and formulas in column D and enter the formula in D1.

VLOOKUP matching 3 columns with 3 others in Google Sheets

I have this formula in D1:
=arrayformula(IFERROR(VLOOKUP(A1:C,H1:K,{4},0)))
I'm trying to match columns A,B,C with columns H,I,J and pull data in column K. The formula is currently not matching correctly. Here is the sheet.
the first argument of VLOOKUP needs to be a single column so the only way how to pull this of with 3 columns is like this:
=ARRAYFORMULA(IFERROR(VLOOKUP(A1:A&B1:B&C1:C, {H1:H&I1:I&J1:J, K1:K}, 2, 0)))

Resources