If/then statements

%3CLINGO-SUB%20id%3D%22lingo-sub-3246443%22%20slang%3D%22en-US%22%3EIf%2Fthen%20statements%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3246443%22%20slang%3D%22en-US%22%3E%3CP%3ELooking%20for%20a%20way%20to%20put%20a%20value%20into%20a%20column%20if%20one%20column%20is%20even%26nbsp%3B%3CSTRONG%3Epartially%3C%2FSTRONG%3E%20true%20to%20another%3C%2FP%3E%3CP%3Eexample%3C%2FP%3E%3CP%3EColumn%20A%20--bobs%20cars%3B%20Column%20B%20--bobs%20trucks%3C%2FP%3E%3CP%3Esince%20both%20have%20'bob'%20in%20the%20column%20want%20a%20'1'%20placed%20in%20column%20C%3C%2FP%3E%3CP%3EIs%20this%20possible%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20the%20help.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3246443%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3246539%22%20slang%3D%22en-US%22%3ERe%3A%20If%2Fthen%20statements%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3246539%22%20slang%3D%22en-US%22%3EHello!%20I%20use%20functions%20like%20this%20all%20the%20time!%20It'll%20sound%20clunky%20but%20each%20piece%20is%20needed%20and%20it%20works%20great!%20Formula%3A%20IF(AND(ISNUMBER(SEARCH(%22bob%22%2C%20%5Bcell%5D))%2C%20ISNUMBER(SEARCH(%22bob%22%2C%20%5Bsecond%20cell%5D)))%2C1%2C0)%20The%20last%201%20and%200%20will%20be%20whatever%20values%20you%20want%20for%20finding%20%22bob%22%20or%20not%3C%2FLINGO-BODY%3E
New Contributor

Looking for a way to put a value into a column if one column is even partially true to another

example

Column A --bobs cars; Column B --bobs trucks

since both have 'bob' in the column want a '1' placed in column C

Is this possible?

 

Thank you for the help. 

6 Replies
Hello! I use functions like this all the time! It'll sound clunky but each piece is needed and it works great! Formula: IF(AND(ISNUMBER(SEARCH("bob", [cell])), ISNUMBER(SEARCH("bob", [second cell]))),1,0) The last 1 and 0 will be whatever values you want for finding "bob" or not

@AnalystNerd but what if it isn't just "bob' in column A?  Basically if any word in column A matches column B want to place the '1' in the 3rd column.  Bob was just an example.

 

I appreciate the help.

@david1776 

 

Is it possible? Yes, and No. It all depends on where the matching string of letters is to be found. On how varied your two columns are going to be.

 

In the example you give, it's quite simple, since the three characters "bob" are the first three characters in each string, for then this formula works

=IF(FIND(LEFT(A1,3),B1),1,0)

But if the "bob" characters are buried elsewhere in the text, it becomes trickier. 

And if your real world issue is far more variable, sometimes with 2 characters matching, sometimes with 4 or 5, all the more elusive.

mathetes_0-1646326181268.png

 

Let's make it more complicated still...if it's any word in any position....

@david1776 

 

Since you're adding complications as we go along, how about giving a much more complete picture here of what you're dealing with. How many words max? What's the bigger picture into which this little task fits?

@david1776 

 

You could try this (adjust range references as applicable and assuming you have the let function), but if your text has characters that are 'special' to xml (such as the & character) in column B, then it will not work. 

 

 

=Let(searchTerms, FILTERXML("<L><I>"&SUBSTITUTE(B1, " ", "</I><I>")&"</I></L>", "//I"),
         matches, SUM(--(ISNUMBER(SEARCH(TRANSPOSE(searchTerms), $A$1:$A$10)))),
         If(iserror(searchterms), "ERROR", --(matches>0)))