Multiple IF Statement

%3CLINGO-SUB%20id%3D%22lingo-sub-2641681%22%20slang%3D%22en-US%22%3EMultiple%20IF%20Statement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2641681%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3BI'm%20trying%20to%20use%20multiple%20IF(SEARCH)%20functions%20to%20find%20text%20within%20a%20specific%20column%20to%20return%20other%20specific%20text.%26nbsp%3B%20I%20have%20attached%20a%20sample.%26nbsp%3B%20I%20would%20like%20to%20write%20an%20IF%20statement%20that%20searches%20for%20%22Black%22%20in%20column%20A%20and%20returns%20%22Black%22%20in%20column%20B%2C%20searches%20for%20%22White%22%20in%20column%20A%20and%20returns%20%22White%22%20in%20column%20%22B%22%20and%20so%20on.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2641681%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-2641843%22%20slang%3D%22en-US%22%3ERe%3A%20Multiple%20IF%20Statement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2641843%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1127026%22%20target%3D%22_blank%22%3E%40katieo8081%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMaybe%20your%20example%20is%20not%20really%20representative%20of%20the%20real%20data%20you'll%20be%20working%20with%2C%20but%20IF%20in%20fact%20the%20color%20in%20question%20is%20always%20the%20first%20word%20in%20the%20text%20being%20searched%2C%20the%20formula%20below%20works%20just%20fine.%20See%20the%20attached%20file%20(i%20changed%20the%20name%2C%20but%20it's%20your%20file%20with%20my%20solution)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DLEFT(%5B%40%5BItem%20Description%5D%5D%2CFIND(%22%20%22%2C%5B%40%5BItem%20Description%5D%5D)-1)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOtherwise%2C%20using%20a%20series%20of%20nested%20IFs%20can%20get%20really%20complicated.%20You%20might%20try%20the%20function%20IFS%20instead.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2641951%22%20slang%3D%22en-US%22%3ERe%3A%20Multiple%20IF%20Statement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2641951%22%20slang%3D%22en-US%22%3E%3CP%3Eif%20you%20did%20a%20query%20from%20a%20system%20you%20should%20include%20the%20sku%20number%20because%20the%20sku%20number%20might%20identify%20the%20color%20of%20the%20product%20and%20base%20your%20formula%20on%20said%20sku%20number%20instead%20of%20re-inventing%20the%20wheel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2642091%22%20slang%3D%22en-US%22%3ERe%3A%20Multiple%20IF%20Statement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2642091%22%20slang%3D%22en-US%22%3EThank%20you%20for%20your%20response.%20Unfortunately%20in%20my%20actual%20data%2C%20the%20SKU%20numbers%20are%20random%20in%20relation%20to%20the%20item%20description.%3C%2FLINGO-BODY%3E
New Contributor

 I'm trying to use multiple IF(SEARCH) functions to find text within a specific column to return other specific text.  I have attached a sample.  I would like to write an IF statement that searches for "Black" in column A and returns "Black" in column B, searches for "White" in column A and returns "White" in column "B" and so on.

8 Replies

@katieo8081 

 

Maybe your example is not really representative of the real data you'll be working with, but IF in fact the color in question is always the first word in the text being searched, the formula below works just fine. See the attached file (i changed the name, but it's your file with my solution)

 

=LEFT([@[Item Description]],FIND(" ",[@[Item Description]])-1)

 

Otherwise, using a series of nested IFs can get really complicated. You might try the function IFS instead.

if you did a query from a system you should include the sku number because the sku number might identify the color of the product and base your formula on said sku number instead of re-inventing the wheel

@mathetes Thank you for your response.  This ended up not being a great representation - the key text identifier is not always the first word.  I tried using IFS, and still got errors.  I'm not great at nesting but that may be my only option.

Thank you for your response. Unfortunately in my actual data, the SKU numbers are random in relation to the item description.
So create a more representative sample for us to work with.

@katieo8081 

 

Yea_So_0-1629051543716.png

 

@katieo8081 

IF( SEARCH... practically never works.  IF() evaluates condition, depends on it returns TRUE or FALSE calculate the result. But if we it returns an error, entire IF() returns error.

 

Usual combination for such cases is to use IF( ISNUMBER( SEARCH( ... 

ISNUMBER returns TRUE if text is found and its position is returned. If error it has another (not number) type, thus ISNUBER returns FALSE.

 

Another point it's not clear would you like return color as very first word of the text or it could be at any place of the text. If former it's easier, just find position of first space and LEFT() text on it.

If the latest I'd create in any place of the workbook the list of words to be found, like

image.png

with that formula could be

=INDEX($D$2:$G$2,
  MMULT(--ISNUMBER(SEARCH($D$2:$G$2,[@[Item Description]])),
        TRANSPOSE($D$1:$G$1)))