SSIS Conditional Split - check if a string has a substring - string

I am wondering if there is a function in SSIS Conditional Split, that would tell me if the string in my datacell has a substring "XYZ" or not. The condition would look like this:
CheckIfValueContainsSubstring("XYZ")
Unfortunately I can't find such function. Is there any way of achieving the goal of separating the record which have the substring from the records which don't have it?
An important note: the substring can be anywhere (so the typical substring function doesn't work for me)

The correct expression for this in SSIS is FINDSTRING.
FINDSTRING( «character_expression», «string», «occurrence» )
MSDNArticle
Similar SO Question

Related

Using the replace function in Netsuite for components in assemblies

Very new to Netsuite. I'm trying to use a saved item search to find all instances of {componentitem} entry is 800484 and replace them with component 516551302688
I'm using the REPLACE function in the saved item search but it doesn't like my formula REPLACE(800484, [, 516551302688]){componentitem}
I'm sure I am doing something wrong in the formula but unsure what it is.
The function signature for REPLACE is:
REPLACE(char, search_string, replacement_string)
char is the text to search in.
search_string is the text to search for.
replacement_string is the text to replace the search_string with, where found.
What you have appears to be more like
REPLACE(search_string, replacement_string)char
The text you want to search in is outside of the function altogether (outside the parentheses that enclose what the function will act on). You also have additional brackets and a comma in your formula.
Based you the information in your question, your formula should be
REPLACE({componentitem}, '800484', '516551302688')
I have wrapped the search and replacement strings in quotes as REPLACE deals with strings. If you leave the quotes off, the database will infer the string values of the numbers given and it will still work, but it's best practice to be explicit.
Note that this will only replace the values within the results of the saved search, and will have no effect on the underlying records. Hopefully you already know this, but I just mention it as the wording of your question makes it appear as if you're expecting it to substitute the actual components.
HTH.

Excel - How can we replace multiple characters or whole words in a cell using LAMBDA()

At risk of being off-topic I decided to do a little Q&A as I'm pretty excited about a new function MS is introducing to Excel365; the LAMBDA() function. If the general opinion is such that this is off-topic, please let me know and I can take down the Q&A.
The LAMBDA() function is basically your way in Excel itself to create your own function. You then can go ahead and call this function throughout your entire workbook. But the absolute great thing (IMHO) about it is that it is able to call itself within the function, thus being recursive!
We all know the tedious nested SUBSTITUTE() functions if one has to swap multiple characters, or clear a string from certain characters and even whole words. So the question is: How do we avoid that and use LAMBDA() to our advantage?
EDIT 22-3-2022:
As per the new functionality, one can choose to opt for:
=CONCAT(TEXTSPLIT(A1,{"+","#","%","*","(",")","!"}))
I'll keep the original answer using LAMBDA() intact below:
Original Answer:
So let's create an example of a string that needs cleaning; a+b#c%d*e(f)g!h.
Formula in B1:
=SUBALL(A1,"+#%*()!","")
Where SUBALL() is the name of our LAMBDA() function I created through the "name manager" menu and reads as follows:
=LAMBDA(str,chrs,sub,IF(chrs="",str,SUBALL(SUBSTITUTE(str,LEFT(chrs),sub),RIGHT(chrs,LEN(chrs)-1),"")))
Core of this formula are the 3 variables:
str - A reference to the string to be cleaned.
chrs - A string of characters to be substituted.
sub - What do we want our characters to be replaced with?
The 4th parameter is a nested IF(). Because of the recursive calls we need a way out of an otherwise infinite loop. Therefor we test if chrs="". If TRUE we return the final string with all substituted characters. If FALSE we call the function again. The great thing here is we can alter all variables! This is important because we can thus SUBSTITUTE() the leftmost character and we can cut that same character of the string of replacements.
We could also take it up a notch and replace element from an array. For example:
The formula in B1:
=SUBALL(A1,{"STR1","STR2","STR3"},"-")
Note, you can also hardcode a single value or reference a single cell (or any vertical range for that matter). Obviously this will impact the way we handle recursion. There may be a prettier way, but I came up with:
=LAMBDA(str,del,sub,IF(COUNTA(del)=1,SUBSTITUTE(str,#del,sub),SUBALL(SUBSTITUTE(str,#del,sub),INDEX(del,SEQUENCE(COUNTA(del)-1,,2)),sub)))
The core of the function is still the same, but as mentioned we have now used an array. So our IF() will no longer check for empty value, but if there is only a single element in our array. If so, it will go do a single SUBSTITUTE(), but if not, then it will recursively call SUBALL() untill we have sliced enough values from our array through INDEX() so all values are substituted.
There you have it, a recursive function that you can now call throughout your entire workbook. Pretty cool.

Excel: Find words of certain length in string?

I have this file where I want to make a conditional check for any cell that contains the letter combination "_SOL", or where the string is followed by any numeric character like "_SOL1524", and stop looking after that. So I don't want matches for "_SOLUTION" or "_SOLothercharactersthannumeric".
So when I use the following formula, I also get results for words like "_SOLUTION":
=IF(ISNUMBER(FIND("_SOL",A1))=TRUE,"Yay","")
How can I avoid this, and only get matches if the match is "_SOL" or "_SOLnumericvalue" (one numeric character)
Clarification: The whole strings may be "Blabla_SOL_BLABLA", "Blabla_SOLUTION_BLABLA" or "Blabla_SOL1524_BLABLA"
Maybe this, which will check if the character after "_SOL" is numeric.
=IF(ISNUMBER(VALUE(MID(A1,FIND("_SOL",A1)+4,1))),"Yay","")
Or, as per OP's request and suggestion, to include the possibility of an underscore after "SOL"
=IF(OR(ISNUMBER(VALUE(MID(A1,FIND("_SOL",A1)+4,1))),ISNUMBER(FIND("_SOL_",A1))),"Yay","")
Here is an alternative way to check if your string contains SOL followed by either nothing or any numeric value up to any characters after SOL:
=IF(COUNT(FILTERXML("<t><s>"&SUBSTITUTE(A1,"_","1</s><s>")&"</s></t>","//s[substring-after(.,'SOL')*0=0]")>0),"Yey","Nay")
Just to use in an unfortunate event where you would encounter SOL1TEXT for example. Or, maybe saver (in case you have text like AEROSOL):
=IF(COUNT(FILTERXML("<t><s>"&SUBSTITUTE(A1,"_","</s><s>")&"</s></t>","//s[translate(.,'1234567890','')='SOL']")>0),"Yey","Nay")
And to prevent that you have text like 123SOL123 you could even do:
=IF(COUNT(FILTERXML("<t><s>"&SUBSTITUTE(A1,"_","1</s><s>")&"</s></t>","//s[starts-with(., 'SOL') and substring(., 4)*0=0]")>0),"Yey","Nay")

Finding question marks in cell string

I would like to find out if a string within a cell in Excel 2010 contains any of the following, and then return a '1'.
?dementia
? dementia
dementia?
dementia ?
I've tried some formulas but they don't seem able to get past the use of the wildcard and the string when combined.
Would anyone have any pointers or advice?
Here is a combination of the suggested answers, and my own work around:
This is the formula you need:
=IF(IFERROR(FIND(A2,$C$3),0)>0,1,0)
where A2 is the string that you are trying to check.
Assuming you don't want to include word ? word and return 1, you can use something like this:
=IF(OR(LEFT(A1,1)="?",RIGHT(A1,1)="?"),1,"")
You will want to use the FIND function (Documentation).
Make sure your search term in in quotation marks.
If you are still having trouble with wildcards, you can try the CHAR function (Documentation). It will return the character as a string. In your case, to get a ?, you would use CHAR(63). I use this chart to keep track of CHAR codes (just use the number and ignore the "Alt")
REVISED:
If I understand the question correctly, you are trying to search long string in a short string list.
The formula you can use is:
=ISTEXT(LOOKUP(99^99,SEARCH(SUBSTITUTE($A$2:$A$5,"?","|"),SUBSTITUTE(C2,"?","|")),$A$2:$A$5))*1
The problem with my prior formula is due to that ? mark because it is being treated as a wild card. Here I have replace it with | (you can change this to a character that you will never use but avoid ? and *). This should work for you now.

Excel: Check if Cell contains one of many substrings. Show substring if True

Currently following method described here: https://exceljet.net/formula/cell-contains-one-of-many-things with a few alterations (to compensate for variable number of substrings).
Code is:
=SUMPRODUCT(--ISNUMBER(SEARCH(OFFSET(Categories!A$1,0,0,COUNTA(Sheet2!A:A),1),[#String])))>0
What I'd like is instead of a "TRUE" or "FALSE" output, is to output the substring that matches. "first encountered" substring would be fine, or "all substrings separated by a comma" or anything like that.
Not really sure where to start, or even if it's possible with Excel formulas.
=LOOKUP(1,0/SEARCH(Substring_List,String),Substring_List)
is probably the most efficient, though you should know that, if more than one entry from Substring_List is found within String, this set-up will return that which occurs latest within that list.
Regards

Resources