Excel: Text mining using IF, ISNUMBER, SEARCH - excel

I'm trying to clean up job title data using the formula below:
=IF(OR(ISNUMBER(SEARCH({"admin","reception","account","finance","HR","public","sales","customer","creative","IT","human"},A1))),"",A1)
It should work by eliminating job titles with any of the texts specified in the quotes above. However, I've encountered an issue where it doesn't. In a case where the job title is Quantity Surveyor, the title contains none of the specified texts but Excel seems to reflect it as such. What am I not doing right here?
Quantity Surveyor Example

To extract the information you are looking for, this is the formula you want to use:
=IFERROR(IF(OR(ISNUMBER(SEARCH({"admin","reception","account","finance","HR","public","sales","customer","creative","human"},A1)),NOT(SEARCH("Quantity",A1))),"",A1),"")

Using countif you don't need to check for errors if they occur:
=IF(OR(COUNTIF(A1,{"admin","reception","account","finance","HR","public","sales","customer","creative","human"}))+COUNTIF(A1,"<>Quantity"),"",A1)

Select the part of formula of search, and then press F9. You will find the match result of 6, where it has original value of 'IT', it means Quantity, has IT.
I really donot know why there is negative vote as not useful.
Here is the formula to solve your problem
=IFERROR(LOOKUP(1,0/FIND({"admin","reception","account","finance","HR","public","sales","customer","creative","IT","human"},A1)),A1)
Of course, it is better to define a range instead of hard code {}, like below
=IFERROR(LOOKUP(1,0/FIND($J$2:$J$7,A2),$K$2:$K$7),A2)

Related

Find value within cell from a series in Excel

I have a list of addresses, such as this:
Lake Havasu,  Lake Havasu City,  Arizona.
St. Johns River,  Palatka,  Florida.
Tennessee River,  Knoxville,  Tennessee.
I would like to extract the State from these addresses and then have a column showing the abbreviated State name (AZ, FL, TN etc.).
I have a table that has the States with their abbreviation and once I extract the State, doing a simple INDEX MATCH to get the abbreviation is easy. I don't want to use text-to-columns because this file will constantly have values added to it and it would be much easier to just have a formula that does the extraction for me.
The ways I've tried to approach this that have failed so far are:
Some kind of SEARCH() function that looks at the full State list and tries to find a value that exists in the cell
A MID or RIGHT approach to only capture the last section but I can't work out how to have FIND only look for the second ", "
A version of INDEX MATCH but that fails because I can't find a good way to search or find the values as per approach (1)
Any help would be appreciated!
Please try this formula, where A2 is the original text.
=FILTERXML("<data><a>" & SUBSTITUTE(A2,", ","</a><a>") & "</a></data>","data/a[3]")
An alternative would be to look for the 2nd comma as shown below. Note that the "50" in the formula is an irrelevant number required by the MID() function. It shouldn't be smaller than the number of characters you need to return, however.
Char(160) is a character that wouldn't (shouldn't) naturally occur in your text, as it might if the text comes from a UNIX database. You can replace it with another one that fits the description.
=TRIM(MID(A2, FIND(CHAR(160),SUBSTITUTE(A2,",",CHAR(160),2)) + 1,50))
The following variation of the above would remove the final period. It will fail if there is anything following the period, such as an unwanted blank. That could be accommodated within the formula as well but it would be easier to treat the original data, if that is an option for you.
=TRIM(MID(LEFT(A2, LEN(A2)-1), FIND(CHAR(160),SUBSTITUTE(A2,",",CHAR(160),2)) + 1,50))
To find the abbreviation I would recommend to use VLOOKUP rather than INDEX/MATCH.
Use this (screenshot refers):
=MID(MID(B3,1,LEN(B3)-1),SEARCH(",",B3,SEARCH(",",B3,1)+1)+3,LEN(B3))

Result not correct when using if, left and search in excel

I am trying to extract the text to the right of a character pattern of form -201*-*- in excel (I also tried using Access, but the issue persists).
For example, in the text:
EP-005-FI6-2012-1-124-000000-1
I want to extract the number 124; the following formula works:
=LEFT(RIGHT(C1,SEARCH("-201*-*-",C1)+1),3)
124
However, when i apply the exact same formula to extract169 from the text below:
NAATS-MG-D6-2017-1-169-070000-1
The formula returns a completely different result:
=LEFT(RIGHT(C540495,SEARCH("-201*-*-",C540495)+1),3)
-16
The pattern is the same, but the results is completely differnt.
My dataset is too big to go row by row fixing the issue...
Seems to be a simple problem, but i can't get this working...
Any thoughts?
Thank you
Your RIGHT() is wrong. Use:
=LEFT(MID(C1,SEARCH("-201?-?-",C1)+8,9999),3)

Excel If statements brackets issue

I am trying to create an IF statement in Excel, in order to group some data into 3 distinct variables. For the purpose of this attempt, I simply want to classify words into people names.
Now, the screenshot shows a simplified version of what I am trying to do, as I am unable to post photos of the full data for security reasons.
As the shot shows, the brackets before F7 and after Joe are in red, but am very confused why. Any help would be appreciated.
Thomas
Excel colour codes brackets when in Edit / Enter mode, to make it easier to identify matching pairs.
You can do it like this:
=IF(ISNUMBER(MATCH(F7,{"Tom","Ed","Joe"},0)),"names","Not names")
Your formula wasn't correct because you didn't have logical values in OR() and the red color was due to Excel pair coloring - not because of error.
To make your formula work as is it would look like:
=IF(OR(F7="Tom",F7="Ed",F7="Joe"),"names","Not names")

Excel 2013, how to us the "search" function like vlookup

Essentially, I am looking for a way to use the "search" function like the "vlookup" function. In my case, I am have a long list, of say, 1000 descriptions of different types of fasteners and I want to classify them according to what they are, (ie. Nut, bolt, washer etc.). However, I can't sort by description or partnumber because they, alphanumerically, don't line up by class. But he descripotion field does say at some point in it, what it is(ie. Nut, bolt, washer etc.).
As said, I have a table of classes, and I am looking for a formula that would look in the "description" field for all the values in the table,and then return that value, or one associated with it (like vlookup does with cell values).
So that, if it found "nut" in the description, it would return "nut", or if it found "bolt" it would return "bolt."
I hope that this question makes sense. Let me also say that I found a way "manually" do this using the search function, along with others, but the formula was very long and each value in my table had to be specially called out. However, I will include the formula I used to make clear what I was trying to do.
See below.
=IF(ISNUMBER(SEARCH($G$2,C3)),$G$2,IF(ISNUMBER(SEARCH($G$3,C3)),$G$3,IF(ISNUMBER(SEARCH($G$4,C3)),$G$4,IF(ISNUMBER(SEARCH($G$5,C3)),$G$5,...IF(ISNUMBER(SEARCH($G$13,C3)),$G$13,"MISC"))))))))))))
You see that with each item you add to your table, you have to add another if loop. I am hoping there is a better way. (I would call it "vsearch" :-) )
Try this formula
=IFERROR(LOOKUP(2^15,SEARCH($G$3:$G$13,C3),$G$3:$G$13),"MISC")
SEARCH returns an array of numbers or errors depending on whether each term is found in C3. By searching for "bignum" (in this case 2^15) which won't be found, the match is always with the last number, i.e. the last matching term in G3:G13.
MATCH can be used to find the text, and INDEX can be used to return the text
using your example, where you are searching in G:
=MATCH("*"&C3&"*",$G:$G,0)
and then index to return the text
=INDEX($G:$G,MATCH("*"&C3&"*",$G:$G,0))
and as a finishing touch, the #VALUE! replacement
=IFERROR(INDEX($G:$G,MATCH("*"&C3&"*",$G:$G,0)),"MISC")

Sharepoint: Calculated Column replace all spaces

Seems like it would be a simple thing really (and it may be), but I'm trying to take the string data of a column and then through a calculated column, replace all the spaces with %20's so that the HTML link in the workflow produced email will actually not break off at the first space.
For example, we have this in our source column:
file:///Z:/data/This is our report.rpt
And would like to end up with this in the calculated column:
file:///Z:/data/This%20is%20our%20report.rpt
Already used the REPLACE, and made up a ghastly super nested REPLACE/SEARCH version, but the problem there is that you have to nest for EACH potential space, and if you don't know how many up front, it doesn't work, or will miss some.
Have any of you come across this scenario and how did you handle it?
Thanks in advance!
As far as I know there is no generic solution using the calculated-column syntax. The standard solution for this situation is using an ItemAdded (/ItemUpdated) event and initializing the field value from code.
I was able to solve this issue for my circumstances by using a series of calculated columns.
In the first calculated column (C1) I entered a formula to remove the first space, something like this:
=IF(ISNUMBER(FIND(" ",[Title])),REPLACE([Title],FIND(" ",[Title]),1,"%20"),[Title])
In the second Calculated column (C2) I used:
=IF(ISNUMBER(FIND(" ",[C1])),REPLACE([C1],FIND(" ",[C1]),1,"%20"),[C1]).
In my case, I wanted to encode upto four spaces, so I used 3 calculated columns (C1, C2, C3) in the same fashion and got the desired result.
This is not as efficient as using a single calculated column, but if SUBSTITUTE will not work in your SharePoint environment, and you cannot use an event handler or workflow, it may offer a workable alternative.
I actually used a slightly different formula, but it was on a work machine to which I don't have access at the moment, so I just grabbed this formula from a similar S.O. question. Any formula that will replace the first occurrence of a space with "%20" will work, the trick is to a) make sure the formula returns the original string unchanged if it does not have more spaces in it, and b) test, test, test. Create a view of your list that has the field you are trying to encode, plus the calculated fields, and see if you are getting the results you want.
so that the HTML link in the workflow produced email will actually not break off at the first space.
The browser only does this if you have not enclosed your link in quotes
If you wrap the link in quotes, it does not cut off at the first space
In a SharePoint Formula it would be:
="""file:///Z:/data/This is our report.rpt"""
becuase two quotes are the SP escape notation to output a quote
You can use this formula (Start trim for 1, in my case was 4):
=IF(ISBLANK([EUR Amount]),"",(TRIM(MID([EUR Amount],4,2))&TRIM(MID([EUR Amount],6,2))&TRIM(MID([EUR Amount],8,2))&TRIM(MID([EUR Amount],10,2))&TRIM(MID([EUR Amount],12,2))&TRIM(MID([EUR Amount],14,2)))*1)

Resources