SOLVED

Return value based on multiple critieria

%3CLINGO-SUB%20id%3D%22lingo-sub-1438949%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1438949%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F688370%22%20target%3D%22_blank%22%3E%40DPifarre%3C%2FA%3E%26nbsp%3BWhy%2010007%20with%20the%20date%20of%2012%20Feb%20shows%26nbsp%3B%3CSPAN%3E5N040001%20in%20your%20expected%20result%3F%20Should%20it%20show%26nbsp%3B5A030001%20instead%20because%2012%20Feb%20belongs%20to%20the%20duration%20starting%20on%2011%20Feb%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3ESimilarly%2C%2010055%20with%20the%20date%20of%2012%20Feb%20showing%26nbsp%3B5A030001%20in%20your%20expected%20result.%20Should%20it%20show%26nbsp%3B5N010001%20instead%20because%2012%20Feb%20belongs%20to%20the%20duration%20ending%20on%202%20Oct%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EIf%20you%20could%20confirm%20your%20rule%2C%20the%20formula%20to%20pull%20the%20desired%20result%20would%20not%20be%20a%20problem.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1439935%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1439935%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675276%22%20target%3D%22_blank%22%3E%40hynguyen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%20you%20are%20correct%20I%20incorrectly%20assigned%20the%20responses.%20Expected%20result%20should%20be%3A%3C%2FP%3E%3CTABLE%20width%3D%22319px%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%2269px%22%20height%3D%2230px%22%3EPers.No.%3C%2FTD%3E%3CTD%20width%3D%2284px%22%20height%3D%2230px%22%3E9-Feb-20%3C%2FTD%3E%3CTD%20width%3D%2284px%22%20height%3D%2230px%22%3E12-Feb-20%3C%2FTD%3E%3CTD%20width%3D%2282px%22%20height%3D%2230px%22%3E3-Nov-20%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2269px%22%20height%3D%2230px%22%3E10007%3C%2FTD%3E%3CTD%20width%3D%2284px%22%20height%3D%2230px%22%3E%3CFONT%20color%3D%22%23FF6600%22%3E5N040001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2284px%22%20height%3D%2230px%22%3E%3CFONT%20color%3D%22%23008000%22%3E5A030001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2282px%22%20height%3D%2230px%22%3E%3CFONT%20color%3D%22%23008000%22%3E5A030001%3C%2FFONT%3E%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%2269px%22%20height%3D%2230px%22%3E10055%3C%2FTD%3E%3CTD%20width%3D%2284px%22%20height%3D%2230px%22%3E%3CFONT%20color%3D%22%23008080%22%3E5N010001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2284px%22%20height%3D%2230px%22%3E%3CFONT%20color%3D%22%23008080%22%3E5N010001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2282px%22%20height%3D%2230px%22%3E%3CFONT%20color%3D%22%23993366%22%3E5A030001%3C%2FFONT%3E%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20appreciate%20your%20pickup%20and%20assistance%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1438758%22%20slang%3D%22en-US%22%3EReturn%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1438758%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI'm%20trying%20to%20return%20the%20WSR%20rule%20(Work%20Schedule%20Roster)%20that%20applied%20to%20an%20individual%20on%20a%20given%20date.%20The%20first%20table%20is%20my%20expected%20result%20for%20the%20given%20values%20in%20the%20data%20table.%26nbsp%3B%3C%2FP%3E%3CTABLE%20width%3D%22600%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%22159px%22%20height%3D%2230px%22%3E%26nbsp%3B%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2230px%22%3EPers.No.%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2230px%22%3E9-Feb-20%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2230px%22%3E12-Feb-20%3C%2FTD%3E%3CTD%20width%3D%2296px%22%20height%3D%2230px%22%3E3-Nov-20%3C%2FTD%3E%3CTD%20width%3D%2253px%22%20height%3D%2230px%22%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22159px%22%20height%3D%2230px%22%3E%26nbsp%3B%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2230px%22%3E10007%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2230px%22%3E%3CFONT%20color%3D%22%23FF6600%22%3E5N040001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2230px%22%3E%3CFONT%20color%3D%22%23008000%22%3E5A030001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2296px%22%20height%3D%2230px%22%3E%3CFONT%20color%3D%22%23008000%22%3E5A030001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2253px%22%20height%3D%2230px%22%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22159px%22%20height%3D%2230px%22%3E%26nbsp%3B%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2230px%22%3E10055%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2230px%22%3E%3CFONT%20color%3D%22%23008080%22%3E5N010001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2230px%22%3E%3CFONT%20color%3D%22%23008080%22%3E5N010001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2296px%22%20height%3D%2230px%22%3E%3CFONT%20color%3D%22%23993366%22%3E5A030001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2253px%22%20height%3D%2230px%22%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22159px%22%20height%3D%2230px%22%3EData%20table%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2230px%22%3E%26nbsp%3B%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2230px%22%3E%26nbsp%3B%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2230px%22%3E%26nbsp%3B%3C%2FTD%3E%3CTD%20width%3D%2296px%22%20height%3D%2230px%22%3E%26nbsp%3B%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22159px%22%20height%3D%2257px%22%3EPers.No.%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2257px%22%3ELast%20name%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2257px%22%3EFirst%20name%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2257px%22%3EWS%20rule%3C%2FTD%3E%3CTD%20width%3D%2296px%22%20height%3D%2257px%22%3EStart%20Date%3C%2FTD%3E%3CTD%20width%3D%2253px%22%20height%3D%2257px%22%3EEnd%20Date%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22159px%22%20height%3D%2284px%22%3E9994%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3EBrown%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3EMary%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3E5A040001%3C%2FTD%3E%3CTD%20width%3D%2296px%22%20height%3D%2284px%22%3E9-Jan-12%3C%2FTD%3E%3CTD%20width%3D%2253px%22%20height%3D%2284px%22%3E31-Dec-99%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22159px%22%20height%3D%2284px%22%3E9998%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3EJones%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3EPhillip%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3E5D220001%3C%2FTD%3E%3CTD%20width%3D%2296px%22%20height%3D%2284px%22%3E1-Apr-18%3C%2FTD%3E%3CTD%20width%3D%2253px%22%20height%3D%2284px%22%3E31-Dec-99%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22159px%22%20height%3D%2284px%22%3E10007%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3EObama%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3ETracey%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3E%3CFONT%20color%3D%22%23FF6600%22%3E5N040001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2296px%22%20height%3D%2284px%22%3E6-Jun-11%3C%2FTD%3E%3CTD%20width%3D%2253px%22%20height%3D%2284px%22%3E10-Feb-20%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22159px%22%20height%3D%2284px%22%3E10007%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3EObama%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3ETracey%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3E%3CFONT%20color%3D%22%23008000%22%3E5A030001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2296px%22%20height%3D%2284px%22%3E11-Feb-20%3C%2FTD%3E%3CTD%20width%3D%2253px%22%20height%3D%2284px%22%3E31-Dec-99%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22159px%22%20height%3D%2284px%22%3E10055%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3EChang%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3EBen%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3E%3CFONT%20color%3D%22%23008080%22%3E5N010001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2296px%22%20height%3D%2284px%22%3E18-Apr-16%3C%2FTD%3E%3CTD%20width%3D%2253px%22%20height%3D%2284px%22%3E2-Oct-20%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22159px%22%20height%3D%2284px%22%3E10055%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3EChang%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3EBen%3C%2FTD%3E%3CTD%20width%3D%2297px%22%20height%3D%2284px%22%3E%3CFONT%20color%3D%22%23993366%22%3E5A030001%3C%2FFONT%3E%3C%2FTD%3E%3CTD%20width%3D%2296px%22%20height%3D%2284px%22%3E2-Nov-20%3C%2FTD%3E%3CTD%20width%3D%2253px%22%20height%3D%2284px%22%3E31-Dec-99%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1438758%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1441853%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1441853%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F688370%22%20target%3D%22_blank%22%3E%40DPifarre%3C%2FA%3E%26nbsp%3BPlease%20see%20the%20attached%20file.%20Your%20data%20will%20stay%20in%20a%20table%20named%20Data%20on%20Tab%20Data%20and%20the%20result%20of%20look%20up%20will%20be%20on%20Tab%20Output.%20Note%20that%20I%20have%20corrected%20your%20End%20date%20to%20the%20year%209999%20instead%20of%201999%20as%20currently.%3C%2FP%3E%3CP%3EI%20use%20Index%2FMatch%20array%20formula%20to%20look%20up.%20Basically%2C%20it%20will%20look%20at%20the%20Data%20Table%2C%20try%20to%20find%20the%20intersection%20of%20column%204%20where%20your%20WS%20Rule%20stays%20and%20the%20row%20where%20all%20conditions%20of%20(Person%20ID%2C%20Start%20date%20%26lt%3B%3D%20your%20lookup%20date%2C%20End%20date%20%26gt%3B%3D%20your%20look%20up%20date)%20are%20satisfied.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1442305%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1442305%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675276%22%20target%3D%22_blank%22%3E%40hynguyen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20a%20comment%2C%20from%20my%20point%20of%20view%20it's%20better%20to%20avoid%20array%20formula%20where%20possible%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DINDEX(Data!%24D%3A%24D%2CMATCH(1%2CINDEX(%20(Data!%24E%3A%24E%26lt%3B%3DB%241)*(Data!%24F%3A%24F%26gt%3B%3DB%241)*(Data!%24A%3A%24A%3D%24A2)%2C0)%2C0))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1444419%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1444419%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BThanks%20for%20your%20suggestion.%3C%2FP%3E%3CP%3EDo%20you%20know%20why%20your%20formulas%20turn%20into%20array%20formulas%20when%20the%20workbook%20is%20opened%20as%20in%20the%20pic%3F%20And%20for%20unknown%20reason%2C%20whenever%20I%20evaluated%20your%20formula%2C%20my%20Excel%20became%20not%20responding%20and%20I%20had%20to%20restart%20the%20application.%20I%20even%20tried%20to%20remove%20the%20array%20brackets%20then%20evaluate%20it%20but%20my%20Excel%20kept%20freezing.%20I%20do%20not%20run%20into%20this%20problem%20when%20evaluating%20my%20array%20formulas.%20Just%20wonder%20what%20causes%20the%20issue%20since%20I%20used%20to%20think%20array%20formulas%20are%20slower%20but%20my%20google%20search%20shows%20some%20tests%20indicating%20they%20actually%20take%20memory%20and%20calculate%20faster.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22MultipleConditionLookup.png%22%20style%3D%22width%3A%20649px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F196863i61D7EB55F5DCB333%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22MultipleConditionLookup.png%22%20alt%3D%22MultipleConditionLookup.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445043%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445043%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675276%22%20target%3D%22_blank%22%3E%40hynguyen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThat's%20strange%2C%20nothing%20new%20in%20such%20formula.%20Do%20you%20have%20the%20same%20if%20enable%20editing%3F%20And%20on%20which%20version%20of%20Excel%20you%20are.%3C%2FP%3E%0A%3CP%3EAs%20for%20array%20vs%20regular.%20With%20dynamic%20arrays%20introduced%20in%20Excel%20this%20question%20is%20gone%2C%20however%2C%20in%20pre-DA%20Excel%20array%20formulas%20are%20preferably%20to%20be%20used%20if%20the%20same%20results%20can't%20be%20achieved%20with%20regular%20formulas.%20IMHO%2C%20performance%20is%20not%20an%20issue%20for%2090%25%20of%20task%20where%20the%20Excel%20is%20used%2C%20you%20will%20see%20no%20difference%20on%20it%20independently%20on%20which%20formulas%20to%20use.%20If%20critical%2C%20that's%20a%20lot%20of%20factors%20to%20be%20taken%20into%20account%2C%20there%20is%20no%20one%20answer%20for%20all%20cases.%26nbsp%3B%20More%20is%20here%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice%2Fvba%2Fexcel%2Fconcepts%2Fexcel-performance%2Fexcel-tips-for-optimizing-performance-obstructions%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EExcel%20performance%3A%20Tips%20for%20optimizing%20performance%20obstructions%3C%2FA%3E%26nbsp%3B.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAt%20the%20same%20time%20quite%20often%20people%20forget%20to%20use%20Ctrl%2BShift%2BEnter%20and%20spent%20lot%20of%20time%20to%20find%20why%20formula%20doesn't%20work.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445358%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445358%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BThe%20formulas%20show%20as%20array%20one%20even%20when%20I%20enabled%20editing.%20I%20am%20using%20Excel%202019.%20The%20weird%20thing%20is%20that%20this%20morning%20I%20tried%20to%20evaluate%20your%20formula%20again%2C%20this%20time%20Excel%20took%20a%20whole%201%20min%20then%20returned%20blank%20in%20the%20output%20field%20of%20the%20Evaluate%20formula%20screen%20and%20the%20Evaluate%20button%20turned%20into%20Restart%20instead.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445375%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445375%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675276%22%20target%3D%22_blank%22%3E%40hynguyen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20sorry%20that%20happened.%20Will%20check%20the%20file%20some%20later%20on%20non-DA%20Excel%2C%20right%20now%20have%20no%20idea%20what%20could%20be%20wrong%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445555%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445555%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675276%22%20target%3D%22_blank%22%3E%40hynguyen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20technique%20of%20inserting%20one%20or%20more%20INDEX%20functions%20at%20certain%20positions%20within%20a%20formula%20so%20as%20to%20avoid%20pressing%20CTRL%2BSHIFT%2BENTER%20does%20not%20at%20all%20mean%20that%20that%20formula%20is%20not%20processed%20as%20an%20array%20formula.%20If%20anything%2C%20the%20non-CSE%20INDEX%20construction%20is%20less%20efficient%20than%20the%20equivalent%20CSE%20one%3B%20after%20all%2C%20an%20extra%20function%20call%20is%20an%20extra%20function%20call...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESince%20such%20constructions%20are%20processed%20in%20exactly%20the%20same%20manner%20as%20the%20CSE%20version%2C%20the%20use%20of%20entire%20column%20references%20is%20to%20be%20avoided.%20The%20following%20formula%2C%20provided%20by%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23000080%22%3E%3CSTRONG%3E%3DINDEX(Data!%24D%3A%24D%2CMATCH(1%2CINDEX(%20(Data!%24E%3A%24E%26lt%3B%3DB%241)*(Data!%24F%3A%24F%26gt%3B%3DB%241)*(Data!%24A%3A%24A%3D%24A2)%2C0)%2C0))%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eis%20having%20to%20process%20%3CU%3E%3CSTRONG%3Emore%20than%203%20million%20cells%3C%2FSTRONG%3E%2C%3C%2FU%3E%26nbsp%3Ban%20astonishing%20number%20for%20a%20single%20formula.%20And%20that's%20just%20for%20one%20instance%20of%20that%20formula%3B%20I%20can%20imagine%20that%20if%20you%20had%20just%20a%20few%20hundred%20or%20so%20of%20the%20above%20then%20your%20spreadsheet%20would%20practically%20come%20to%20a%20halt.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EReduce%20the%20upper%20row%20being%20referenced%20to%20a%20suitably%20low%2C%20though%20sufficient%2C%20value.%20Better%20still%2C%20use%20either%20table%20ranges%20(which%20automatically%20detect%20the%20last-used%20cell%20within%20the%20range)%20or%20else%20define%20your%20own%20dynamic%20ranges.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445569%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445569%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F676180%22%20target%3D%22_blank%22%3E%40Jos_Woolley%3C%2FA%3E%26nbsp%3B%2C%20in%20theory%20you%20are%20correct.%20In%20practice%20such%20formulas%20never%20process%203%20million%20cells%2C%20they%20stop%20on%20first%20match.%20Even%20with%20no%20match%20it%20works%20fast%20if%20major%20part%20of%20the%20cells%20is%20blank.%20At%20least%20on%20relatively%20new%20versions%20of%20Excel.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIMHO%2C%20for%20such%20cases%20dynamic%20ranges%20complicate%20the%20maintenance%2C%20but%20if%20people%20who%20will%20work%20with%20the%20file%20are%20familiar%20with%20them%20-%20yes%2C%20better%20to%20use.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445577%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445577%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20afraid%20that's%20simply%20not%20correct.%20I'm%20not%20referring%20to%20MATCH%3B%20even%20before%20the%20formula%20arrives%20at%20the%20MATCH%20part%20it%20has%20to%20process%20this%20product%20of%20arrays%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%23000080%22%3E%3CSTRONG%3E(Data!%24E%3A%24E%26lt%3B%3DB%241)*(Data!%24F%3A%24F%26gt%3B%3DB%241)*(Data!%24A%3A%24A%3D%24A2)%3C%2FSTRONG%3E%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20I%20assure%20you%20that%20every%20single%20one%20of%20the%26nbsp%3B%3CSTRONG%3E3%2C145%2C728%3C%2FSTRONG%3E%20cells%20referenced%20within%20Data!%24A%3A%24A%2C%20Data!%24E%3A%24E%20and%20Data!%24F%3A%24F%20will%20be%20processed%2C%20irrespective%20of%20whether%20they%20are%20empty%20or%20beyond%20the%20last-used%20cell%20in%20those%20ranges%20and%20also%20independent%20of%20the%20MATCH%20function%20to%20which%20they%20are%20being%20passed.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445603%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445603%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F676180%22%20target%3D%22_blank%22%3E%40Jos_Woolley%3C%2FA%3E%26nbsp%3BThat%20explains%20why%20my%20Excel%20kept%20frozen%20when%20evaluating%20the%20formula.%20I%20also%20try%20to%20avoid%20referring%20a%20whole%20column%2Frow%20as%20much%20as%20possible%20in%20any%20formula.%20Thanks%20for%20your%20explanation.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1445660%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1445660%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675276%22%20target%3D%22_blank%22%3E%40hynguyen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou're%20welcome!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1447132%22%20slang%3D%22en-US%22%3ERe%3A%20Return%20value%20based%20on%20multiple%20critieria%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1447132%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F675276%22%20target%3D%22_blank%22%3E%40hynguyen%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20that%20works%20great%20and%20you've%20expressed%20it%20simply.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi,

I'm trying to return the WSR rule (Work Schedule Roster) that applied to an individual on a given date. The first table is my expected result for the given values in the data table. 

 Pers.No.9-Feb-2012-Feb-203-Nov-20 
 100075N0400015A0300015A030001 
 100555N0100015N0100015A030001 
Data table    
Pers.No.Last nameFirst nameWS ruleStart DateEnd Date
9994BrownMary5A0400019-Jan-1231-Dec-99
9998JonesPhillip5D2200011-Apr-1831-Dec-99
10007ObamaTracey5N0400016-Jun-1110-Feb-20
10007ObamaTracey5A03000111-Feb-2031-Dec-99
10055ChangBen5N01000118-Apr-162-Oct-20
10055ChangBen5A0300012-Nov-2031-Dec-99
14 Replies
Highlighted

@DPifarre Why 10007 with the date of 12 Feb shows 5N040001 in your expected result? Should it show 5A030001 instead because 12 Feb belongs to the duration starting on 11 Feb?

Similarly, 10055 with the date of 12 Feb showing 5A030001 in your expected result. Should it show 5N010001 instead because 12 Feb belongs to the duration ending on 2 Oct?

If you could confirm your rule, the formula to pull the desired result would not be a problem.

Highlighted

@hynguyen 

Yes you are correct I incorrectly assigned the responses. Expected result should be:

Pers.No.9-Feb-2012-Feb-203-Nov-20
100075N0400015A0300015A030001
100555N0100015N0100015A030001

 

I appreciate your pickup and assistance

Highlighted
Best Response confirmed by DPifarre (New Contributor)
Solution

@DPifarre Please see the attached file. Your data will stay in a table named Data on Tab Data and the result of look up will be on Tab Output. Note that I have corrected your End date to the year 9999 instead of 1999 as currently.

I use Index/Match array formula to look up. Basically, it will look at the Data Table, try to find the intersection of column 4 where your WS Rule stays and the row where all conditions of (Person ID, Start date <= your lookup date, End date >= your look up date) are satisfied. 

Highlighted

@hynguyen 

As a comment, from my point of view it's better to avoid array formula where possible

=INDEX(Data!$D:$D,MATCH(1,INDEX( (Data!$E:$E<=B$1)*(Data!$F:$F>=B$1)*(Data!$A:$A=$A2),0),0))

 

Highlighted

@Sergei Baklan Thanks for your suggestion.

Do you know why your formulas turn into array formulas when the workbook is opened as in the pic? And for unknown reason, whenever I evaluated your formula, my Excel became not responding and I had to restart the application. I even tried to remove the array brackets then evaluate it but my Excel kept freezing. I do not run into this problem when evaluating my array formulas. Just wonder what causes the issue since I used to think array formulas are slower but my google search shows some tests indicating they actually take memory and calculate faster.MultipleConditionLookup.png

Highlighted

@hynguyen 

That's strange, nothing new in such formula. Do you have the same if enable editing? And on which version of Excel you are.

As for array vs regular. With dynamic arrays introduced in Excel this question is gone, however, in pre-DA Excel array formulas are preferably to be used if the same results can't be achieved with regular formulas. IMHO, performance is not an issue for 90% of task where the Excel is used, you will see no difference on it independently on which formulas to use. If critical, that's a lot of factors to be taken into account, there is no one answer for all cases.  More is here Excel performance: Tips for optimizing performance obstructions . 

At the same time quite often people forget to use Ctrl+Shift+Enter and spent lot of time to find why formula doesn't work.

Highlighted

@Sergei Baklan The formulas show as array one even when I enabled editing. I am using Excel 2019. The weird thing is that this morning I tried to evaluate your formula again, this time Excel took a whole 1 min then returned blank in the output field of the Evaluate formula screen and the Evaluate button turned into Restart instead.

Highlighted

@hynguyen 

I'm sorry that happened. Will check the file some later on non-DA Excel, right now have no idea what could be wrong

Highlighted

@hynguyen 

 

The technique of inserting one or more INDEX functions at certain positions within a formula so as to avoid pressing CTRL+SHIFT+ENTER does not at all mean that that formula is not processed as an array formula. If anything, the non-CSE INDEX construction is less efficient than the equivalent CSE one; after all, an extra function call is an extra function call...

 

Since such constructions are processed in exactly the same manner as the CSE version, the use of entire column references is to be avoided. The following formula, provided by @Sergei Baklan:

 

=INDEX(Data!$D:$D,MATCH(1,INDEX( (Data!$E:$E<=B$1)*(Data!$F:$F>=B$1)*(Data!$A:$A=$A2),0),0))

 

is having to process more than 3 million cells, an astonishing number for a single formula. And that's just for one instance of that formula; I can imagine that if you had just a few hundred or so of the above then your spreadsheet would practically come to a halt.

 

Reduce the upper row being referenced to a suitably low, though sufficient, value. Better still, use either table ranges (which automatically detect the last-used cell within the range) or else define your own dynamic ranges.

 

Regards

Highlighted

@Jos_Woolley , in theory you are correct. In practice such formulas never process 3 million cells, they stop on first match. Even with no match it works fast if major part of the cells is blank. At least on relatively new versions of Excel.

 

IMHO, for such cases dynamic ranges complicate the maintenance, but if people who will work with the file are familiar with them - yes, better to use.

Highlighted

@Sergei Baklan 

 

I'm afraid that's simply not correct. I'm not referring to MATCH; even before the formula arrives at the MATCH part it has to process this product of arrays:

 

(Data!$E:$E<=B$1)*(Data!$F:$F>=B$1)*(Data!$A:$A=$A2)

 

and I assure you that every single one of the 3,145,728 cells referenced within Data!$A:$A, Data!$E:$E and Data!$F:$F will be processed, irrespective of whether they are empty or beyond the last-used cell in those ranges and also independent of the MATCH function to which they are being passed.

 

Regards

Highlighted

@Jos_Woolley That explains why my Excel kept frozen when evaluating the formula. I also try to avoid referring a whole column/row as much as possible in any formula. Thanks for your explanation.

Highlighted

@hynguyen 

 

You're welcome!

Highlighted

@hynguyen 

Thank you that works great and you've expressed it simply.