Excel, using a second index match if first is empty - excel

I was wondering if theres an easy way to setup a formula that is an index match one a sheet of data, and then if there was no match, look somewhere else.
I have new results which I want to look up from, then if not I have historical results to look up from. I dont want to combine the data as I dont want the historical numbers to change any averages in the new results.
I could use two columns each with a different index match and then some IF, OR statements but I'd like to know if theres a way of doing it all in one forumla.
Thanks

MATCH will return an error where a matching value is not found. This can be used to switch to an alternative match attempt, eg:
=IFERROR(INDEX(Sheet1!A:A,MATCH(C1,Sheet1!B:B,0)),INDEX(Sheet2!A:A,MATCH(C1,Sheet2!B:B,0)))

Related

Excel - Index/Match to Parse Column Data Until Desired Value Shows

I'm not sure the best way to word this question, but basically I have a big list of different names and IDs that will be visited multiple times with data pulled from a Survey123 form. One of the fields is asking if a part has been repaired, which will be no a maximum of 3 times before turning yes.
I'm using Index/Match to keep track of the dates the visits took place, but if I try it for the repair column it will always just return the first value in the repair column. Is there a way I can have it parse all the repair column values and change the result if it is Yes?
Here is a visual of what I'm trying to achieve, using Index/Match will stop at the first result rather than cycling through.
You may try below formula. If any of visit has Yes in repaired column then it will return Yes or will return No.
=IF(SUMPRODUCT((A3:A5=F3)*(B3:B5=G3)*(D3:D5="Yes"))>0,"Yes","No")
Or you can use XLOOKUP() with Search_Mode option -1 means search last to first order.
=XLOOKUP(1,(A3:A5=F3)*(B3:B5=G3),D3:D5,"",0,-1)
You can use FILTER to achieve this
=FILTER(C2:C4,(A2:A4=F4)*(B2:B4=G4)*(C2:C4="Yes"),"No")

Can I use MINIFS or INDEX/MATCH on two non-contiguous ranges...?

Problem is straightforward, but solution is escaping. Hopefully some master here can provide insight.
I have a big data grid with prices. Those prices are ordered by location (rows) and business name (cols). I need to match the location/row by looking at two criteria (location name and a second column). Once the matching row is found (there will always be a match), I need to get the minimum/lowest price from two ranges within the grid.
The last point is the real challenge. Unlike a normal INDEX or MINIFS scenario, the columns I need to MIN aren't contiguous... for example, I need to know what the MIN value is between I4:J1331 and Q4:U1331. It's not an intersection, it's a contiguous set of values across two different arrays.
You're probably saying "hey, why don't you just reorder your table to make them contiguous"... not an option. I have a lot of data, and this spreadsheet is used for a bunch of other stuff. So, I have to work with the format I have, and that means figuring out how to do a lookup/min across multiple non-contiguous ranges. My latest attempt:
=MINIFS(AND($I$4:$J$1331,$K$4:$P$1331),$B$4:$B$1331,$A2,$E$4:$E$1331,$B2)
Didn't work, but it should make it more clear what I'm trying to do. There has GOT to be an easy way to just tell excel "use these two ranges instead of one".
Thanks,
Rick
Figured it out. For anyone else who's interested, there doesn't seem to be any easy way to just "AND" arrays together for a search (Hello MS, backlog please). So, what I did instead was to just create multiple INDEX/MATCH arrays inside of a MIN function and take the result. Like this:
MIN((INDEX/MATCH ARRAY 1),(INDEX/MATCH ARRAY 2))
They both have identical criteria, the only difference is the set of arrays being indexed in each function. That basically gives me this:
MIN((match array),(match array))
And Min can then pull the lowest value from either.
Not as elegant as I'd like... lots of redundant code, but at least it works.
-rt

Excel: Returning values from a range that haven't already been specified

I have a dataset in long format with a unique ID representing people at different points in time. I already have a list of ID's with the first code, but would like to add a column for the second and third code, if available.
An example of the data, with what the output should look like at the bottom
I already have the first two columns in this example. I was thinking I would specify that I want to look at the values that are not the first code, and output a different code in the range if available, otherwise it returns blank. I also want to be able to use the command with few modifications in a third cell for a third code, again as long as it exists.
Ideally this can all be done without the use of vba, however if that would be easier, then by all means go ahead. Any solution not necessarily following my logic map are appreciated as well. Thanks in advance for the help!

Need to understand fomula re: excel search for a string in a table and return string if true

I've adapted this solution from a couple of years ago:
=LOOKUP(2^15,FIND(Keywords,A2),Categories)
I use this for searching within a description field for keywords in a named list, in order to return a corresponding category from an adjacent named list.
However I do not understand the significance of 2^15. Can someone explain?
Also it's unclear in what order the search operates. If two keyword options were "check" and "deposit," and they were assigned to different categories, but both appeared in the same description field cell, how do I know which will be found first? Is it placement in the string, or order in the list?
2^15 is simply an arbitrarily large number, which lookup attempts to find - when it can't find it, it takes the next lowest number.
Effectively your formula looks at Keywords, and attempts to find the value in A2. For each word that actually matches A2, it provides a non-error message. Then out of the whole list, it attempts to find that line number in categories, resulting in many errors, and a single correct value. Lookup picks the value by using 2^15. Though this seems to be a weird way of doing it; it is likely a holdover of pre-2007, as Lookup is generally used now only for backwards compatibility purposes. Also using 1 instead of 2^15 worked for a couple of simple cases that I tried when writing this up.

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")

Resources