Finding a value from array in File Path [Excel] - excel

I have a little problem with Excel.
I'm trying to compare if one of several specific words occur in a path.
This is what I do with the following function:
=IF(ISERROR(SEARCH($C$2:$C$4,A2)),"NO","YES")
However, the result is always "No".
Example data:
Does anyone have an idea?

SEARCH($C$2:$C$4,A2)
will return an array of a number or a #VALUE! errors.
If you wrap that in ISNUMBER it will return an array of TRUE;FALSE...
To see if ANY of the values are TRUE, wrap that in an OR and use that in your IF statement.
Of course, since this is an array formula, you have to enter it by holding down ctrl + shift while hitting Enter
=IF(OR(ISNUMBER(SEARCH($C$2:$C$4,A2))),"Yes","No")
You can see what is happening by using the Formula Evaluation tool

You can use SUMPRODUCT with ISNUMBER and SEARCH
=IF(SUMPRODUCT(--ISNUMBER(SEARCH(C2:C4,A2)))>0,"YES","NO")

Related

Return array from INDEX function in Excel?

I'm trying to use INDEX in array format in Excel but I'm running into problems.
From this question: Return array from INDEX function?, it seems that "INDEX (like VLOOKUP) doesn't return an array of values (except in some convoluted circumstances)"
So I'm wondering what alternatives there are.
I'm trying to do this:
=qlTimeSeries( ,
INDEX({39618,39619,39638,39639},{2,3,4}),
INDEX({18,19,38,39},{2,3,4})
)
and Index is not returning an array.
Any alternative idea how to get the result I am trying to get with INDEX({39618,39619,39638,39639},{2,3,4})?
i.e. from {39618,39619,39638,39639} get {39619,39638,39639} back?
NOTE: Instead of INDEX({39618,39619,39638,39639},{2,3,4}) my spreadsheet in fact uses a dynamic array of dates and the objective is to drop the first element of the array {39618,39619,39638,39639} which is why I am using INDEX.
EDIT: Looking for a solution that avoids using VBA
Try this array formula:
= INDEX({39618,39619,39638,39639},N(IF({1},{2,3,4})))
This will return what you desire: {39619,39638,39639}.
Note this is an array formula, so you must press Ctrl+Shift+Enter on the keyboard after typing this formula instead of just pressing Enter.
(Also note this works with dynamic ranges, not just hard-coded arrays.)

Which built-in excel functions treat ranges as arrays?

For example =SUMPRODUCT(A2:A10-10) does, but =SUM(A2:A10-10) does not. Specifically in my situation I wish =MEDIAN(ABS(A2:A10-MEDIAN(A2:A10))) did; however sadly it does not, and if I knew which built in functions convert the ranges into arrays before they evaluate then I might be able to reformulate something that gives me what I'm looking for...
there are some natural array type formulas like SUMPRODUCT and some of the options in AGGREGATE, as well as some financial functions.
Many can be "forced" into array mode by simply using Ctrl-Shift-Enter instead of Enter when exiting edit mode.
For example your formula:
=MEDIAN(ABS(A2:A10-MEDIAN(A2:A10)))
If it is confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode will "Force" the Array. If done correctly the Excel will put {} around the formula.
The INDEX function has an Array Form.
=SUM(INDEX((A2:A10)-10, , ))
In the above, INDEX is returning an array of values but a wrapping SUM is required to collect a total. The blank parameters represent all rows and all columns in the range (e.g. A2:A10) specified. All rows and all columns in the range can also be represented with zeroes in place of the blank parameters.
With 2 to 10 in A2:A10, your MEDIAN example would return 14 from,
=MEDIAN(INDEX(ABS((A2:A10)-MEDIAN(A2-A10)), , ))
(without CSE)
Use the Evaluate Formula command to see more of the inner workings of this style of INDEX use.

Search multiple items returning error

I have an excel formula that I want to return the rightmost data after finding one of three things. However if the first search term is not found it returns an error:
=IFERROR(RIGHT(A1, LEN(A1)-SEARCH({")",">","#"},A1)),"")
How can I make this work for all three search terms?
Currently the other search terms evaluate to #VALUE! which, if the first term is not found, is causing the formula to fail.
Try this modified version, entered as an Array formula (Press Ctrl-Shift-Enter rather than just Enter)
=RIGHT(A1, LEN(A1)-MAX(IFERROR(SEARCH({")",">","#"},A1),0)))
The Max get the largest result from Search.
If none of the characters appear in the string, it returns the whole string

ISNUMBER statement only reading first condition

Good day,
I am trying to insert this formula into excel to search for specific terms in a cell, and return a value "50" if the term is found.
I have been able to successfully implement this using the below primitive formula:
=IF(C1394<>70,C1394,IF(ISNUMBER(SEARCH("*PD*",B1394)),"50",IF(ISNUMBER(SEARCH("*OD*",B1394)),"50",IF(ISNUMBER(SEARCH("*OC*",B1394)),"50",IF(ISNUMBER(SEARCH("*OF*",B1394)),"50",IF(ISNUMBER(SEARCH("*PC*",B1394)),"50",IF(ISNUMBER(SEARCH("*MS*",B1394)),"50",C1394)))))))
I tried to make my formula more efficient and dynamic using the below approach, however excel only reads the first condition "PD" and ignores the rest
=IF(C8266 =70,IF(--ISNUMBER(SEARCH({"*PD*","*OD*","*OC*","*OF*","*PC*","*MS*"},B8266)),"50",C8266),C8266)
Can someone please advise what am I doing wrong?
You're just missing an OR clause, see this: http://www.mrexcel.com/forum/excel-questions/601195-check-multiple-text-strings-cell.html#post2977162
So you want:
=IF(C8266=70,IF(OR(ISNUMBER(SEARCH({"*PD*","*OD*","*OC*","*OF*","*PC*","*MS*"},B8266))),"50",C8266),C8266)
What you are doing wrong is you are trying to evaluate an array within a formula that doesn't usually evaluate arrays. You evaluate such formulae by pressing and holding Ctrl+Shift and then press Enter.
Otherwise, your formula can be shortened to the below:
=IF(OR(ISNUMBER((C8266=70)*SEARCH({"PD","OD","OC","OF","PC","MS"},B8266))),"50",C8266)
SEARCH does not require wildcards.
A boolean multiplied by a number gives a number. An error multiplied by a number gives an error. So you can safely combine the first and second checks together and drop the --.
OR is then used to check if there is at least 1 number within the array of numbers and/or errors.
Similarly array invoked (with Ctrl+Shift+Enter).

Excel index match formula with large if paramaters

Im wondering if someone can help insert an OR option into the below formula
=INDEX(B2:B211,MATCH(LARGE(IF(C2:C211=HomeTeam,B2:B211,""),1),B2:B211,0))
Ive tried the below but unfortunately this brings back an incorrect result
=INDEX(B2:B211,MATCH(LARGE(IF(OR(C2:C211=HomeTeam,D2:D211=HomeTeam),B2:B211,""),1),B2:B211,0))
Any help is appreciated
Short answer is to use + rather than OR - the OR function returns a single value not an array as required here, so it doesn't work as expected in array formulas
Try like this
=INDEX(B2:B211,MATCH(LARGE(IF((C2:C211=HomeTeam)+(D2:D211=HomeTeam),B2:B211),1),B2:B211,0))
I'm assuming that HomeTeam is a named range (hence no quotes) - is that a single value?
As you are returning the value itself here you don't really need INDEX and MATCH in any case, you can use just
=LARGE(IF((C2:C211=HomeTeam)+(D2:D211=HomeTeam),B2:B211),1)

Resources