Excels INDEX MATCH - Finding multiple matches -
------a ----------------- b ----------------------c ------------------------d 1 --first--------------last-----------------start date--------------end date 2 --john--------------smith--------------08/08/2014------------01/01/2015 3---john--------------smith--------------08/11/2014------------17/11/2014 4---john--------------smith--------------06/06/2014------------23/12/2014 5---abel--------------jones--------------14/05/2014------------29/04/2015 6---abel--------------jones--------------04/07/2014------------26/04/2015
sometimes on spread sheet duplicate names. example table above (with random data) there 3 john's , 2 abel's. these names start , end date. if have start or end date earlier or later previous entry name, calculate longest range (john smith) doing
=max($d2:$d4)-min($c2:$c4)
this give 209 days.
also, want formula automatically recognize if name has duplicate within range, , if retrieve date. in order this, perform index match function follows.
=index(c:c, match(1,index((a:a=$a3)*(b:b=$b3),0),0))
this should give 08/08/2014.
combine 2 formulas perform search first name , last name comparing start , end date of matches, find longest possible date range.
=max( (index($c:$c, match(1,index(($a:$a=$a4)*($b:$b=$b4),0),0))) :$d4) - min( (index($d:$d, match(1,index(($a:$a=$a4)*($b:$b=$b4),0),0))) :$c4)
again gives 209.
problem having formula, when index match function scans through list of names find duplicate, if does, match against first. if there more 1 duplicate, ignore it. there 3 john smiths in table, want formula check longest range between duplicates. make sense , possible?
i define ranges more surgically when using array formulas. given small data set, array formula gives expected result:
=max(if(index($a$2:$a$6&" "&$b$2:$b$6, 0) = a2&" "&b2, $d$2:$d$6)) - min(if(index($a$2:$a$6&" "&$b$2:$b$6, 0) = a2&" "&b2, $c$2:$c$6))
...confirmed control+shift+enter activate array.
Comments
Post a Comment