I am trying to do a partial match of Products (Column B) to DB (Column H). Column B however has many partial names within the cell. The entirety of Column H needs to be searched for a partial match of Column B, if a match is found then the cell name from column H needs to be input into column C.
Link to sample Google sheet: https://docs.google.com/spreadsheets/d/1ZvIbZQ9zsLd6w1uGgSbQ3v-QFebMYrlQfvdsLCfEwAg/edit?usp=sharing
Any advice on how to do this would be appreciated.
In order to look for a substring that would correspond to all the cell values from H2:H70 in B2 (and the subsequent values of the column B) you will be wanting to use the function REGEXMATCH that compares a text (in the case below B2) with a regular expressing (each of the values from H2:H70). If it finds a match then it returns the value of column H by using the IF function and if it doesnt it returns empty.
As we are comparing the range H2:H70 to B2 this will return an array of possible matches or not matches (emtpy after the IF) and therefore this array must be handled with ARRAYFORMULA.
Then we are using QUERY to only return the array values that are not empty. This will leave us with an array of values of just the actual matches found (in case there are more than one). As I imagined that you want all the matches in a single cell I am taking all the matches array values and joining them in a single array separated by a space using TEXTJOIN.
Finally, I am using IFERROR to return empty in case no matches were found.
=IFERROR(TEXTJOIN(" ",TRUE,QUERY(ARRAYFORMULA(IF(REGEXMATCH(B2, $H$1:$H$70),$H$1:$H$70,"")),"where Col1 is not null")))
Related
I'm trying to separate specific rows of data into a new sheet, based on the text string in Column H / 8;
=query({attendees_list!A2:N2},"select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13,Col14 where Col8='Show1 - Adult (Earlybird Pricing)'",1)
The query is working, in that it returns columns 1-14 from the 'attendees_list' sheet, but it doesn't seem to be applying the "where" condition, as its returning all rows regardless of the Column H value, rather than returning the specified value; 'Show1 - Adult (Earlybird Pricing)')
Here is a document with the example of the issue
https://docs.google.com/spreadsheets/d/1LEISiYnFeOloA5FDmzA3B5fhXVY_YJiivxedR5qurpU/edit?usp=sharing
I've tried different string quote types (ie; ''&"") but I can't figure out the issue.
Any idea where I'm going wrong here?
the issue is in the range A2:N2 <- that's one row and then 3rd query argument set to 1 will treat that single row as a header row and always output it whatever you setup in 2nd query argument
try:
=QUERY({attendees_list!A2:N},
"select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13,Col14
where Col8 = 'Show1 - Adult (Earlybird Pricing)'", )
Refer the worksheet here - https://docs.google.com/spreadsheets/d/1g3mthqijmB7lySfKUvt2NjYT-zVA5oyXr1hJKcJZkdc - Feel fee to edit.
I'm currently trying to get data from a specific column each time the data validation is changed.. It should pull the Names corresponding to FALSE values.. Currently I'm achieving this using multiple IF functions.. If there is a way to directly match the validation input to the row header and then get the values, it would be super great.
See my duplicate sheet ("Erik Help"):
=FILTER(E2:E,FILTER(F2:J,F1:J1=B2)=FALSE)
In plain English, this reads as follows: "Return any names in Column E where the header in in Columns F to J matches the value in cell B2 and where the corresponding value for the name is FALSE."
This formula is written flexibly, assuming that you will have more than two names in Column E within your real sheet. If there are more columns, just extend both instances of J to match the new rightmost column.
As you'll see in my sample sheet, I've already found the match between two columns (C and D) and put the results in E. So these values correspond to a value from C, but are in a different order.
Now I want the values from column A, but I need for the formula to match E's value to the correct row in column C first to get the correct corresponding subject in column A.
LMK if my description needs improvement, I just rewrote it about 3 times.
I think this does what you want. There's no index function for array so you have to reconstruct a vlookup.
=filter(If(E2:E="","",vlookup(E2:E,{C:C,A:A},2,false)),not(isblank(A2:A)))
try:
=INDEX(IFNA(VLOOKUP(E2:E, {C:C, A:A}, 2, )))
I'm looking for a formula which lets me search for matches between two columns, and where a match is found, add the associated value from a 3rd column.
Example
If a fruit in column B matches any of the values in Column A, add the associated value from Column C. Here you have 2 grapefruit matches ($2) and 2 orange matches ($.5) so you get $5.
Is there a formula to do this automatically? Huge thanks for any help!
A simple version is
=sum(filter(C2:C8, match(B2:B8, A2:A4, 0)))
which looks up each element of B2:B8 in the range A2:A4, and if there is a match, includes the corresponding entry from C in the sum.
If you expect the entries in column A to grow (so they won't always stay A2:A4), the following may be preferable:
=sum(filter(C2:C8, match(B2:B8, filter(A2:A, len(A2:A)), 0)))
Here the fixed range A2:A4 is replaced by the output of a filter, which returns all nonempty cell in A2:A.
I am trying to conditionally format a row in Google Sheets based on the result of a QUERY operation. I can get the QUERY to return the value I want (either 0 or non-zero), however QUERY insists on returning a header row.
Since the QUERY now takes up 2 rows for every row of data, changing the format of the row based off the QUERY result starts to get weird after just a few rows.
The problem I am ultimately trying to solve in the case where I enter a list of names, and I want to compare each name to a list of "NSF Names". If a name is entered, and it exists on the NSF list, I would like to flag the entry by highlighting the row red.
Help is greatly appreciated.
Edit: Formula, as requested:
=query(A:D,"select count(A) where C contains '"&E1&"' and D contains '"&E2&"'")
A:D is the data set (A is a numeric ID, B is full name, C and D are first and last names respectively).
E1 and E2 are placeholders for the person's first and last name, but would eventually be replaced with parsing the person's name, as it's inputted on the sheet (TRIM(LEFT(" ", A2) etc...)
I can get the QUERY to return the value I want (either 0 or non-zero),
however QUERY insists on returning a header row.
There might be better ways to achieve what you want to do, but in answer to this quote:
=QUERY(A:D,"select count(A) where C contains '"&E1&"' and D contains '"&E2&"' label count(A) ''")
A query seems a long-winded approach (=countifs(C1:C7,E$1,D1:D7,E$2) might be adequate) but the label might be trimmed off it by wrapping the query in:
index(...,2)