partial google sheets string cell comparison - google-sheets

The Primary Sheet has basic info ( narrowed here ), including
Column B - a flag to say "Yes" or "No/Stop"
Column C - a Company Name
A Second sheet "stopphrases" will have a growing list of words and phrases in it. If one of these words match first sheet called "data" > Column C (Company Name), Column B will updated to a "No"
IE -
1) If stopphrases!sheet, range A1:A25 contains "UPS"
2) And the Primary Sheet has "UPS Shipping"
This "partial" match should catch it and insert flag into data.Column B
=MATCH(""&stopphrases!A1:A10&"", C6,0)
I seem to be able to check a partial from a single cell and check the range, but not got the other way - get the partial words from multiple cells and check against a single cell.
I also tried
(If Statement)
=IF(COUNTA(IFERROR(FILTER(stopphrases!$A$1:$A$25,stopphrases!$A$1:$A$25=C2))),"Yes","No")
The results I am looking for are
So again -
IF StopPhrases!A1:A25 Range has a phrase "UPS"
THen any entry in first sheet, Company Name, Column B that CONTAINS "UPS" - IE "UPS Shipping" should flag - this way I can run a condition.
The end result is if a match occurs a "stop" happens and that record doesn't get processed in other spreadsheets that are connected.

You can use regexmatch or regexextract to do this:
first to make the dynamic list of stopphrases you use a JOIN function, an INDIRECT function so you can use COUNTA to allow for it to automatically add the correct number of phrases,
=JOIN("|",INDIRECT("E2:E"&COUNTA(E2:E)+1))
Then you use arrayformula and regexmatch to dynamically match your list of stop words:
=ARRAYFORMULA(IF(ISTEXT(B1:B),if(REGEXMATCH(B1:B,$D$1),"STOP","GO"),))
=ARRAYFORMULA(IF(ISTEXT(B1:B),if(REGEXMATCH(LOWER(B1:B),$D$1),"STOP","GO"),))

Related

Is there any formula to select the column dynamically in the below case?

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.

Is it possible to use two cells of criteria to return a value from a third column?

I have an Google sheets file with two sheets. I'm trying to reference one sheet's text based on two cells of criteria using a formula in the other sheet. I have one sheet that looks similar to this -
And another that looks like this -
I would like to put a formula on the second sheet that basically says - look on the first sheet for the values in columns A and B and return me the value in column C. The tricky part is - the values in the second sheet may be inverted or there may be an instance where only one value is present, like in row 1 in the first sheet. Also the formula should only fill in a value if both columns match. All text combinations in both sheets are unique.
Is it possible to do this with text? Thank you for your help!
Try the following
=ArrayFormula((IFERROR(VLOOKUP(R2:R&S2:S,{O2:O&P2:P,Q2:Q},2,0))&
IFERROR(IF((R2:R<>"")*(S2:S<>""),VLOOKUP(R2:R&S2:S,{P2:P&O2:O,Q2:Q},2,0),""))))
(Do adjust locale and ranges according to your needs)
Functions used:
ArrayFormula
IFERROR
IF
VLOOKUP
If you can use two keys concated in the lookup table as a virtual key (i.e. make a key like "CAT|DOG"), then you can use that to look in the secondary table.
If you can't guarantee the sort order of the two keys in the secondary table, you can use the following technique to "sort" the two keys so you can make a single lookup key that's always in one stable order.
Sample Table
A
B
C
D
E
SortedKey
Cat
Dog
TRUE
Cat
Dog
CatDog
Dog
Cat
FALSE
Cat
Dog
CatDog
Formulas
Sample formulas for row #1.
For column C, use formula: =A1<B1
For column D, use formula: =IF(C1=TRUE, A1, B1)
For column E, use formula: =IF(C1=TRUE, B1, A1)
For SortedKey, use formula: =concat(D1, E1)

vlookup a value and return if it is after a certain date

Hello I Have a sheet with a list of names, medications, statuses and correlating dates on a spreadsheet. On a separate spreadsheet I would like to be able to type in a date and status (ex. "Pending", "active") and have the correlating patient names come up.
If i Type in 5/6/21 and then "active" I would like the formula to search the master-sheet and return names of patients whos status is "Active" after the Date 5/6/21.
I can't open your second sheet, but based on the first one, I've added a date input in cell F2.
Sheets QUERY is a powerful function that is similar to SQL. It can be used to display data from a dataset based on certain parameters (like your date search, and status = active).
In the example, the following QUERY formula goes in cell H1, but you can move it to a different tab if needed, obviously referencing 'DATA'!A:E etc.
=if(isblank(F2),,iferror(query(A:E,"where D > date '"&text(F2,"yyyy-mm-dd")&"' and lower(E) contains 'active' order by D,A",1),"No result"))
functions
isblank - if cell F2 is blank (the date search), then nothing.
iferror - if the query doesn't return any values, just output the wording 'No result'.
query function - as per the parameters below.
The range of your data is cells A:E.
The where clause basically says that the value in col D needs to be greater than the date within the single quotes '', which contains "&text(F2,"yyyy-mm-dd")&", which is the value of cell F2, formatted as text in the structure yyy-mmm-dd.
Placing "&<Sheets function>&" within the single quotes '' allows you to put another Sheets function in the query syntax, in this example the text function that formats the input of cell F2 as a date yyyy-mm-dd.
The where clause also includes an and where the lowercase of column E, lower(E) contains the word 'active'.
The results are ordered by column D then column A.
The ,1 at the end of the query tells it to treat the first row of data as headings. If it was data and not a heading, then it would be ,0.
Let me know if you need it implementing on your actual sheet.

Sort the value of a column with a relative position (using an other column data order)

I've created a form to collect data from user A in a sheet and reformat it for user B in the other sheet.
I have to sort the data for user B. I'm using vlookup to sort the column of values from the form to a new sheet (sort based on the order of the 'value description column'). It's working.
My problem is that when a new column is added to the first sheet (the form) the column range is modified and the index parameter in vlookup is not good anymore. So I lost everything on my second sheet.
How can I do to have a solid link with the column in the first sheet even if it's position change?
you can make use of INDIRECT with COUNTA and SUBSTITUTE. something like:
=INDIRECT("Sheet1!A1:"&SUBSTITUTE(ADDRESS(1, COUNTA(Sheet1!1:1), 4), 1, "")
this will count non-empty cells in row 1 of Sheet1 and converts that number to later which is used in constructing the range put together by indirect formula and all of it can be placed in vlookup as same as you would place any ther regular range.

Google sheets conditional formatting based on =QUERY result

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)

Resources