In Google Sheets, I have 2 columns (A and B) of text and I'm trying to set up conditional formatting to identify partial duplicates for when these 2 criteria are both met:
Text in A exactly matches with any other cell in A
and
Any of the individual words in cell B match any of the words in any other cell in B
So, if A2 = "target.com" and B2 = "Big Bonus"
I want it to flag any other cells where A = "target.com" and B = "Bonus Donuts" or "Biggest Exciting Bonus Ever" (because "Bonus" is identified as the duplicate) or "Exciting Big Day" (because "Big" is identified as the duplicate). I need it to be case-agnostic.
Nothing I have tried has even come close to working, so I won't include any of it here.
Sample Data: https://docs.google.com/spreadsheets/d/1DO-0uJRf6MOJ7fJiza5MAmFNIqpCwJ4WMH28j6wp22w/edit#gid=0
I've added a new sheet ("Erik Help") to your sample spreadsheet, with the following custom CF rule applied to the range A3:B ...
=AND($A3=$A$1, REGEXEXTRACT(LOWER($B3),SUBSTITUTE(TRIM(LOWER($B$1))," ","|")))
$A3=$A$1 should be self-explanatory.
For the rest, you see I used LOWER to make the comparisons caps-agnostic. I applied TRIM, just in case you accidentally added any spaces into the B1 string and then just replaced remaining spaces with the pipe symbol, which is interpreted by REGEXEXTRACT as OR.
If you don't want partial word matching (Big in Biggest), try this in the conditional custom formula:
=and($A3=$A$1, regexextract(" "&lower($B3)&" "," "&substitute(lower($B$1)," "," | ")&" "))
Related
I'm struggling with writing the proper syntax for this formula in Google Sheets. In one sheet called Game Log, in the H column I have data that can be a range of names (1 - 10 names per row). I'm trying to construct a COUNTIF statement that would search for the name in all the rows for that column. There can be several other names in the same column so I need to use the wildcard * to find any occurrence of the name in each row. So for example, the current code below would count all occurrence of Adam in the rows.
=COUNTIF('Game Log'!H3:H102, "*Adam*")
What I would like to do is replace the hard codes "Adam" with a cell reference (in this case B2). Is it possible to combine that cell reference with the wild card? The know the code below doesn't work (as it would return text counting occurrences of B2), but is something like this possible?
=COUNTIF('Game Log'!H3:H102, "*B2*")
Have you tried something like this?
=COUNTIF('Game Log'!H3:H102, "*" & B2 & "*")
That ought to look for any string value, followed by the cell value, followed again by any string value. It's essentially just performing separate checks, in sequence, which allows you to search for different value types (in this case string wildcard + cell value + string wildcard).
I can't seem to find the right equation to find a cell from a row that matches only a few specific characteristics. In this example, I am trying to find the equation for Column D which would be the cell in A that has the same cells for B & C.
Hope this makes sense!
I'll provide two options.
If you're sure your data will only ever have zero or one match, you can place the following formula into D2 of an otherwise empty range D2:D...
=ArrayFormula(IF(A2:A="",,SUBSTITUTE(VLOOKUP(B2:B&C2:C,{B2:B&C2:C,A2:A},2,FALSE)&VLOOKUP(B2:B&C2:C,SORT({B2:B&C2:C,A2:A,ROW(A2:A)},3,0),2,FALSE),A2:A,"")))
However, if you think more than one match may turn up and you want "None" to be returned if there is no match, you can use the following formula in D2 or an otherwise empty range D2:D...
=ArrayFormula(IF(A2:A="",,REGEXREPLACE(REGEXEXTRACT(REGEXREPLACE(SUBSTITUTE(VLOOKUP(B2:B&C2:C,TRIM(SPLIT(FLATTEN(QUERY(QUERY({B2:B&C2:C&"~",A2:A&","}, "Select MAX(Col2) where Col2 IS NOT NULL GROUP BY Col2 PIVOT Col1"),, 9^9)),"~")),2,FALSE),A2:A,""),"^[,\s]+$","None"),"([^,\s].+[^,\s])[,\s]*$"),"[,\s]+",", ")))
The second formula will work even if there will only ever be zero or one match; it's just not necessary to have it be that lengthy. And the second formula is only as lengthy because it was unclear from your posted examples whether the data in Col A, B and C will really only ever be one word or not; so the formula is built to assume there will not always be one-word strings in those columns.
Either formula will provide results for the entire column without dragging.
Here's an option, You can use this formula in column D2:
=iferror(textjoin(", ",true,query($A$2:$C,"Select A where A is not null and A != '"&$A2&"' and B = '"&$B2&"' and C = '"&$C2&"'",0)),"None")
Limitation:
You need to manually drag the formula to its succeeding rows. Arrayformula() cannot be used in looping the query string values.
What it does?
Using query(), filter the data from A2:C that has the same current row last name(Column B) and food(Column C) at the same time having a different first name(Column A)
If there are multiple results, use textjoin() to combine them with ", " as its delimiter.
If there is no matched found, it will return an error, hence use iferror() to set the default value to "None"
Output
In Google Sheets,
I'm trying to indicate whether each cell in a specific column (Let's call it "Target column") contains any of the words listed in a group of cells (Let's call it "Word warehouse").
The idea is that each cell in Target column that isn't empty AND doesn't contain any word from Word warehouse will add +1 to some other cell in the spreadsheet.
For example, if my column contains any of {"No", "Not", "None", "Negative"} then I will ignore it. If it contains anything else (and is not empty) then it will be counted.
Using Search or Vlookup doesn't help since they expect a single string value rather than a range of cells (Word warehouse).
You can try following formula:
=--ArrayFormula((SUM((--ISNUMBER(SEARCH(TRANSPOSE($D$1:$D$4),A1))))=0)*(A1<>""))
In example range A1:A7 is Target column and range D1:D4 is Word warehouse.
I may have an answer that works for you. See my sample sheet here.
The key formula, C2 in the sample sheet, is:
=QUERY(A2:B,"SELECT A WHERE UPPER(A) MATCHES '" &
UPPER(".*" & JOIN(".*|.*",FILTER(B2:B,B2:B<>"")) & ".*") &
"' ",0)
where A2:A is your "target column" and B2:B is your "word warehouse".
This tests each word or phrase in column A against the (filtered) list of words (or phrases) in column B, and produces a list of all of the ones that match.
By counting the total number of entries in column A, and subtracting the count of the number that matched, you get a count of all of the ones that didn't match. This can be done with this formula - D2 in my sample sheet:
=COUNTA(A2:A) -
COUNTA(QUERY(A2:B,"SELECT A WHERE UPPER(A) MATCHES '" &
UPPER(".*" & JOIN(".*|.*",FILTER(B2:B,B2:B<>"")) & ".*") &
"' ",0))
Note that I've made the match insensitive to case. This can easily be removed, by removing the upper function in the two places in the formula. This also matches on partial matches, eg "Catcher" matches "cat" in the word warehouse. This could also be easily changed.
I also only count one match per phrase, even if it contains several of the words in the warehouse.
Let me know if this helps.
In a Google Sheets spreadsheet, I have the cell A1 with value "people 12-14 ABC". I want to extract the exact match "ABC" into another cell. The contents of cell A1 can change, e.g. to "woman 60+ ABCD". For this input, I would want to extract "ABCD". If A1 was instead "woman 12-20 CAE", I would want "CAE".
There are 5 possible strings that the last part may be: (ABC, ABCD, AB, CAE, C), while the first portions are very numerous (~400 possibilities).
How can I determine which of the 5 strings is in A1?
If the first part "only" has lower case or numbers and the last part "only" UPPER case,
=REGEXREPLACE(D3;"[^A-E]";)
Anchor: Space
=REGEXEXTRACT(A31;"\s([A-E]+)$")
If you can guarantee well-formatted input, this is simply a matter of splitting the contents of A1 into its component parts (e.g. "gender_filter", "age range", and "my 5 categories"), and selecting the appropriate index of the resultant array of strings.
To convert a cell's contents into an array of that content, the SPLIT() function can be used.
B1 = SPLIT(A1, " ")
would put entries into B1, C1, and D1, where D1 has the value you want - provided your gender filter and age ranges.
Since you probably don't want to have those excess junk values, you want to contain the result of split entirely in B1. To do this, we need to pass the array generated by SPLIT to a function that can take a range or array input. As a bonus, we want to sub-select a part of this range (specifically, the last one). For this, we can use the INDEX() function
B1 = INDEX(SPLIT(A1, " "), 1, COUNTA(SPLIT(A1, " ")))
This tells the INDEX function to access the first row and the last column of the range produced by SPLIT, which for the inputs you have provided, is "ABC", "ABCD", and "CAE".
I am working with a google sheet that in one column can hold 1+ strings of numbers, and in another column, needs to read those numbers in and concat them with a link.
What I mean by this is and what works thus far: Column A - 324243324 || Column B - =concat("google.com/", Column A) = google.com/324243324
What I hope to get working: Column A - 324243324 5004938 || Column B - =concat("google.com/", Column A) = google.com/324243324 google.com/5004938
Is this possible? Thank you for your help!
You want to (a) split the input by spaces; (b) prepend each part by "google.com/"; and (c) join again, separated by spaces. This is achieved by
=join(" ", arrayformula("google.com/" & split(A1, " ")))
The & operator is equivalent to CONCAT but easier to type. arrayformula indicates that the operation is done on an array (the output of split).
However, these links will not be hyperlinked; joining makes them into plain text. To keep them functional, remove the last step, "join", so that each link appears in its own cell.