SOLVED

Combining Dynamic Arrays

%3CLINGO-SUB%20id%3D%22lingo-sub-2986652%22%20slang%3D%22en-US%22%3ECombining%20Dynamic%20Arrays%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2986652%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20currently%20working%20on%20a%20project%20that%20requires%20me%20to%20pull%20unique%20warehouse%20locations%20from%20a%20table%2C%20and%20list%20our%20different%20SKUs%20assigned%20to%20each%20location.%20Right%20now%20I'm%20using%20multiple%20dynamic%20ranges%20to%20filter%20and%20sort%20out%20the%20data%20I%20need%20and%20using%20more%20dynamic%20ranges%20on%20top%20of%20that%20to%20pull%20out%20each%20SKU%20stored%20in%20each%20location.%20The%20result%20is%20a%20ton%20of%20different%20dynamic%20ranges%20and%20calculations%20that%20are%20slowing%20the%20workbook%20to%20a%20crawl.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20to%20combine%20these%20arrays%20into%20one%3F%20I've%20tried%20experimenting%20with%20MMULT%20and%20a%20couple%20other%20methods%20but%20haven't%20had%20any%20luck.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20workbook%20is%20structured%20as%20follows%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFirst%20formula%20in%20AA2%20is%20this%2C%20meant%20to%20pull%20a%20list%20of%20all%20locations%20that%20have%20a%20max%20capacity%20under%2025%25%20(getting%20low%20and%20need%20to%20be%20replenished.%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3D%2BFILTER(Table2%5BCode%5D%2C(Table2%5B%25%20of%20Max%20Capacity%5D%26lt%3B%3D25%25)*(Table2%5B%25%20of%20Max%20Capacity%5D%26gt%3B0%25)*(Table2%5BType%5D%3D%22Non-Fixed%22))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22DKoontz_0-1637345926263.png%22%20style%3D%22width%3A%20752px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F328242iB0B048754A41EE89%2Fimage-dimensions%2F752x171%3Fv%3Dv2%22%20width%3D%22752%22%20height%3D%22171%22%20role%3D%22button%22%20title%3D%22DKoontz_0-1637345926263.png%22%20alt%3D%22DKoontz_0-1637345926263.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESecond%20for%20the%20SKU%20list%2C%20looks%20at%20that%20location%20and%20pulls%20out%20all%20of%20the%20individual%20parts%20stored%20at%20that%20location.%20I%20tried%20making%20this%20filter%20on%20the%20first%20dynamic%20range%20but%20can't%20get%20it%20to%20work%20properly%20so%20its%20individually%20copied%20down%20for%20each%20item.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3D%2BTRANSPOSE(UNIQUE(FILTER(InvTable%5BItemCode%5D%2CInvTable%5BStorLocCode%5D%3DAA2)))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22DKoontz_1-1637346127909.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F328243i7B15DA245D156015%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22DKoontz_1-1637346127909.png%22%20alt%3D%22DKoontz_1-1637346127909.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20formula%20in%20Z%20just%20looks%20up%20all%20of%20the%20parts%20in%20each%20location%20and%20sums%20demand%20which%20is%20pulled%20from%20another%20column.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3D%2BIFERROR(SUM(XLOOKUP(AB2%23%2C%24T%242%23%2C%24U%242%23))%2C%22%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20then%20created%20my%20own%20dynamic%20range%20using%20the%20indirect%20and%20a%20count%20of%20how%20many%20items%20are%20in%20Z%2C%20and%20ranked%20the%20locations%20in%20order%20from%20greatest%20demand%20to%20least.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3D%2BSORT(FILTER(Inventory!Z2%3AINDIRECT(%22AA%22%26amp%3BInventory!%24Z%241)%2CInventory!Z2%3AINDIRECT(%22Z%22%26amp%3BInventory!%24Z%241)%26gt%3B%3DLARGE(Inventory!Z2%3AINDIRECT(%22Z%22%26amp%3BInventory!%24Z%241)%2C45))%2C1%2C-1)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20to%20combine%20the%20dynamic%20ranges%20in%20AA%20and%20AB%3F%20I%20think%20it%20would%20really%20cut%20down%20on%20processing%20and%20speed%20up%20the%20workbook.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20can%20share%20the%20workbook%20if%20needed%2C%20just%20have%20to%20scrub%20it%20a%20bit%20first.%20Thank%20you!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2986652%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-2986770%22%20slang%3D%22en-US%22%3ERe%3A%20Combining%20Dynamic%20Arrays%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2986770%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F993615%22%20target%3D%22_blank%22%3E%40DKoontz%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20guess%20you%20may%20XMATCH(Locations%2C%26nbsp%3BInvTable%5BStorLocCode%5D)%2C%20return%20Parts%20by%20INDEX%20with%20above%20and%20combine%20both%20arrays%20with%20IF%20or%20CHOOSE.%20Better%20with%20sample%2C%20above%20is%20just%20an%20idea%20if%20I%20understood%20correctly%20your%20case.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2986911%22%20slang%3D%22en-US%22%3ERe%3A%20Combining%20Dynamic%20Arrays%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2986911%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%3EAttached%20a%20scrubbed%20and%20changed%20up%20sample%20but%20all%20methods%20are%20the%20same.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3EINDEX(InvTable%5BItemCode%5D%2CXMATCH(FILTER(Table2%5BCode%5D%2C(Table2%5B%25%20of%20Max%20Capacity%5D%26lt%3B%3D25%25)*(Table2%5B%25%20of%20Max%20Capacity%5D%26gt%3B0%25)*(Table2%5BType%5D%3D%22Non-Fixed%22))%2CInvTable%5BStorLocCode%5D))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Ewhich%20returns%20the%20first%20part%20of%20each%20location%20specified%2C%20but%20if%20there%20are%20multiple%20parts%20in%20one%20location%20that%20gets%20left%20off.%20Not%20sure%20how%20to%20combine%20the%20arrays%20with%20choose.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%20that%20I'm%20thinking%20it%20through%2C%20the%20sum%20that%20I'm%20doing%20W2%20is%20dependent%20on%20the%20AB%20formulas%20being%20distinct%20dynamic%20ranges.%20I'll%20play%20around%20with%20xmatch%20and%20see%20if%20I%20can%20come%20up%20with%20a%20better%20method.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20your%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2987702%22%20slang%3D%22en-US%22%3ERe%3A%20Combining%20Dynamic%20Arrays%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2987702%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%3EThis%20is%20EXACTLY%20what%20I%20was%20wondering%20was%20possible.%20Using%20LET()%20to%20define%20all%20of%20the%20separate%20ranges%20then%20combining%20them%20with%20CHOOSE()%20makes%20a%20lot%20sense.%20Looks%20like%20this%20helped%20the%20calculation%20speed%20a%20bit%20too.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'll%20definitely%20start%20incorporating%20this%20regularly%20and%20playing%20around%20with%20it%20a%20bit%20more.%20I%20really%20should%20use%20index%20more%2C%20indirect%20is%20my%20go%20to%20for%20situations%20like%20this%20but%20index%20has%20much%20more%20flexibility.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel-formula%22%3E%3CCODE%3E%3DLET(k%2C%20SEQUENCE(%20ROWS(%24T%242%23)%20)%2C%20IFERROR(%20SUM(%20XLOOKUP(%20AB2%23%2C%20INDEX(%24T%242%23%2Ck%2C1)%2C%20INDEX(%24T%242%23%2Ck%2C2)%20)%20)%2C%22%22)%20)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EThis%20is%20really%20interesting%2C%20using%20the%20sequence%20as%20your%20lookup%20and%20return%20array%20is%20not%20something%20that%20I%20would%20have%20thought%20possible.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20so%20much!%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EAlso%20I%20like%20the%20spaces%20after%20calling%20a%20function%2C%20very%20clean%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2989323%22%20slang%3D%22en-US%22%3ERe%3A%20Combining%20Dynamic%20Arrays%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2989323%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F993615%22%20target%3D%22_blank%22%3E%40DKoontz%3C%2FA%3E%26nbsp%3BHi%2C%3C%2FP%3E%3CP%3E%26gt%3B%26nbsp%3B%3CSPAN%3EIs%20there%20a%20way%20to%20combine%20these%20arrays%20into%20one%3F%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20am%20not%20sure%20my%20suggestion%20is%20what%20you%20need%20and%20since%20the%20attached%20file%20is%20not%20xlsx%20I%20cannot%20download%20it%20(security%20reasons)%20but%20to%20answer%20your%20question%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EYes%20-%20you%20have%20an%20anchor%20cell%20AA2%20that%20can%20tell%20how%20many%20rows%20you%20need%20in%20the%20combined%20array.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EYou%20also%20know%20that%20demand%20is%20one%20column%20to%20the%20left%20(since%20I%20guess%20you%20may%20want%20to%20include%20them)%20and%20the%20items%20are%20one%20column%20to%20the%20right%2C%20equals%20width%20%3D%203%20plus%20an%20unknown%20maximum%20number%20of%20items%20per%20DC%2Fwarehouse%20being%20at%20least%20one.%20This%20will%20catch%20only%20the%20first%20unless%20you%20change%203%20to%20a%20number%20large%20enough%20to%20cover%20an%20expected%20maximum.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DOFFSET(AA2%3B0%3B-1%3BROWS(AA2%23)%3B3)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bosinander_1-1637443217356.png%22%20style%3D%22width%3A%20740px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F328377i236F03A09133B252%2Fimage-dimensions%2F740x246%3Fv%3Dv2%22%20width%3D%22740%22%20height%3D%22246%22%20role%3D%22button%22%20title%3D%22bosinander_1-1637443217356.png%22%20alt%3D%22bosinander_1-1637443217356.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20needed%20width%20of%20the%20combined%20array%20can%20be%20found%20by%20counting%20the%20number%20of%20items%20per%20DC%3B%3C%2FP%3E%3CP%3EA16%20lists%20the%20unique%20combinations%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DUNIQUE(FILTER(Table2%5BDC%5D%3ATable2%5BCode%5D%3BTable2%5B%25%20of%20Max%20Capacity%5D%26lt%3B%3DE2))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bosinander_2-1637443481547.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F328378iADEFF42E574807C7%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22bosinander_2-1637443481547.png%22%20alt%3D%22bosinander_2-1637443481547.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3ED16%20visualizes%20the%20number%20of%20items%20per%20DC%20-%20this%20is%20not%20needed.%3C%2FP%3E%3CP%3EE16%20finds%20the%20%3CSTRONG%3Emax%20number%20of%20items%3C%2FSTRONG%3E%20per%20DC%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DLET(DCsWithItemsUnderLimit%3BINDEX(A16%23%3B0%3B1)%3B%0Aoutput%3BMAX(COUNTIFS(DCsWithItemsUnderLimit%3BUNIQUE(DCsWithItemsUnderLimit)))%3B%0Aoutput%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%20the%20calculated%20max%20no%20of%20items%20added%20to%20previous%20figure%203%20(or%20change%20it%20to%20the%20actual%20no%20of%20columns%20to%20get%20a%20dynamic%20full%20width)%2C%20the%20combined%20array%20including%20all%20items%20can%20look%20like%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DLET(maxNoOfItems%3BE16%3B%0AanchorCell%3BAA2%3B%0AfullWidth%3BCOLUMNS(Z2%3AAB2)-1%2BmaxNoOfItems%3B%0AleftCol%3BOFFSET(anchorCell%23%3B0%3B-1)%3B%0AcurrentRegion%3BOFFSET(leftCol%3B0%3B0%3B%3BfullWidth)%3B%0AcurrentRegion%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bosinander_3-1637444281881.png%22%20style%3D%22width%3A%20721px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F328379i8217629B79AA55D4%2Fimage-dimensions%2F721x128%3Fv%3Dv2%22%20width%3D%22721%22%20height%3D%22128%22%20role%3D%22button%22%20title%3D%22bosinander_3-1637444281881.png%22%20alt%3D%22bosinander_3-1637444281881.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20finally%20sort%20and%20delimit%20(if%20wanted)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DLET(maxNoOfItems%3BE16%3B%0AanchorCell%3BAA2%3B%0AfullWidth%3B2%2BmaxNoOfItems%3B%0AleftCol%3BOFFSET(anchorCell%23%3B0%3B-1)%3B%0AcurrentRegion%3BOFFSET(leftCol%3B0%3B0%3B%3BfullWidth)%3B%0Aoutput%3BINDEX(SORT(currentRegion%3B%3B-1)%3BSEQUENCE(AB23)%3BSEQUENCE(%3BfullWidth))%3B%0Aoutput%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22bosinander_4-1637444423425.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F328380i933E7A6F8A28E0F0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22bosinander_4-1637444423425.png%22%20alt%3D%22bosinander_4-1637444423425.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Frequent Contributor

I'm currently working on a project that requires me to pull unique warehouse locations from a table, and list our different SKUs assigned to each location. Right now I'm using multiple dynamic ranges to filter and sort out the data I need and using more dynamic ranges on top of that to pull out each SKU stored in each location. The result is a ton of different dynamic ranges and calculations that are slowing the workbook to a crawl.

 

Is there a way to combine these arrays into one? I've tried experimenting with MMULT and a couple other methods but haven't had any luck.

 

The workbook is structured as follows:

 

First formula in AA2 is this, meant to pull a list of all locations that have a max capacity under 25% (getting low and need to be replenished. 

=+FILTER(Table2[Code],(Table2[% of Max Capacity]<=25%)*(Table2[% of Max Capacity]>0%)*(Table2[Type]="Non-Fixed"))

 

DKoontz_0-1637345926263.png

 

Second for the SKU list, looks at that location and pulls out all of the individual parts stored at that location. I tried making this filter on the first dynamic range but can't get it to work properly so its individually copied down for each item.

=+TRANSPOSE(UNIQUE(FILTER(InvTable[ItemCode],InvTable[StorLocCode]=AA2)))

DKoontz_1-1637346127909.png

 

The formula in Z just looks up all of the parts in each location and sums demand which is pulled from another column.

=+IFERROR(SUM(XLOOKUP(AB2#,$T$2#,$U$2#)),"")

 

I then created my own dynamic range using the indirect and a count of how many items are in Z, and ranked the locations in order from greatest demand to least.

=+SORT(FILTER(Inventory!Z2:INDIRECT("AA"&Inventory!$Z$1),Inventory!Z2:INDIRECT("Z"&Inventory!$Z$1)>=LARGE(Inventory!Z2:INDIRECT("Z"&Inventory!$Z$1),45)),1,-1)

 

Is there a way to combine the dynamic ranges in AA and AB? I think it would really cut down on processing and speed up the workbook.

 

I can share the workbook if needed, just have to scrub it a bit first. Thank you!

6 Replies

@DKoontz 

I guess you may XMATCH(Locations, InvTable[StorLocCode]), return Parts by INDEX with above and combine both arrays with IF or CHOOSE. Better with sample, above is just an idea if I understood correctly your case.

 

 

@Sergei Baklan 

 

Attached a scrubbed and changed up sample but all methods are the same.

 

I tried:

INDEX(InvTable[ItemCode],XMATCH(FILTER(Table2[Code],(Table2[% of Max Capacity]<=25%)*(Table2[% of Max Capacity]>0%)*(Table2[Type]="Non-Fixed")),InvTable[StorLocCode]))

which returns the first part of each location specified, but if there are multiple parts in one location that gets left off. Not sure how to combine the arrays with choose.

 

Now that I'm thinking it through, the sum that I'm doing W2 is dependent on the AB formulas being distinct dynamic ranges. I'll play around with xmatch and see if I can come up with a better method. 

 

Thanks for your help.

 

best response confirmed by DKoontz (Frequent Contributor)
Solution

@DKoontz 

Sorry, I misunderstood. If we speak about "Low Non-Fixed Locations by Demand" or like, that's array of array. If modify, when with lambdas and supporting functions.

 

However, I'd modify a bit existing formulae. First, avoid using of INDIRECT() and define dynamic ranges with INDEX() instead. For example, W2# could be

=LET(
 zRangeL,  Inventory!Z2:INDEX( Z2:Z1000,Inventory!$Z$1 ),
 zRange,   Inventory!Z2:INDEX( Z2:Z1000,Inventory!$Z$1-1 ),
 aaRange,  Inventory!Z2:INDEX( AA2:AA1000, Inventory!$Z$1 - 1 ),
SORT(FILTER( aaRange, zRange >= LARGE( zRangeL, 45)),1,-1) )

Spills could be combined like in H2#

=LET(
   Part,      UNIQUE( FILTER( InvTable[ItemCode], InvTable[Zone Code]=J1)),
   Qty,       SUMIFS( InvTable[Quantity], InvTable[ItemCode], Part, InvTable[Zone Code],$J$1),
   ZOne,      SUMIFS( InvTable[Pallet], InvTable[ItemCode], Part, InvTable[Zone Code],$J$1),
   ZTwo,      SUMIFS( InvTable[Pallet],InvTable[ItemCode],Part,InvTable[Zone Code],$K$1),
   Projection, XLOOKUP( Part,InvTable[ItemCode],InvTable[Projection]),
 CHOOSE( {1,2,3,4,5}, Part, Qty, ZOne, ZTwo, Projection) )

Plus if no special reasons I'd don't use binary format, dynamic arrays are not optimized for it.

 

Please check attached.

@Sergei Baklan 

This is EXACTLY what I was wondering was possible. Using LET() to define all of the separate ranges then combining them with CHOOSE() makes a lot sense. Looks like this helped the calculation speed a bit too.

 

I'll definitely start incorporating this regularly and playing around with it a bit more. I really should use index more, indirect is my go to for situations like this but index has much more flexibility.

 

=LET(k, SEQUENCE( ROWS($T$2#) ), IFERROR( SUM( XLOOKUP( AB2#, INDEX($T$2#,k,1), INDEX($T$2#,k,2) ) ),"") )

This is really interesting, using the sequence as your lookup and return array is not something that I would have thought possible.

 

Thank you so much! 


Also I like the spaces after calling a function, very clean

@DKoontz , you are welcome, thank you for the feedback.

@DKoontz Hi,

Is there a way to combine these arrays into one?

I am not sure my suggestion is what you need and since the attached file is not xlsx I cannot download it (security reasons) but to answer your question;

Yes - you have an anchor cell AA2 that can tell how many rows you need in the combined array.

You also know that demand is one column to the left (since I guess you may want to include them) and the items are one column to the right, equals width = 3 plus an unknown maximum number of items per DC/warehouse being at least one. This will catch only the first unless you change 3 to a number large enough to cover an expected maximum.

 

=OFFSET(AA2;0;-1;ROWS(AA2#);3)

 

bosinander_1-1637443217356.png

 

The needed width of the combined array can be found by counting the number of items per DC;

A16 lists the unique combinations

 

=UNIQUE(FILTER(Table2[DC]:Table2[Code];Table2[% of Max Capacity]<=E2))

 

bosinander_2-1637443481547.png

D16 visualizes the number of items per DC - this is not needed.

E16 finds the max number of items per DC

 

=LET(DCsWithItemsUnderLimit;INDEX(A16#;0;1);
output;MAX(COUNTIFS(DCsWithItemsUnderLimit;UNIQUE(DCsWithItemsUnderLimit)));
output
)

 

 

Using the calculated max no of items added to previous figure 3 (or change it to the actual no of columns to get a dynamic full width), the combined array including all items can look like

 

=LET(maxNoOfItems;E16;
anchorCell;AA2;
fullWidth;COLUMNS(Z2:AB2)-1+maxNoOfItems;
leftCol;OFFSET(anchorCell#;0;-1);
currentRegion;OFFSET(leftCol;0;0;;fullWidth);
currentRegion
)

 

bosinander_3-1637444281881.png

 

And finally sort and delimit (if wanted)

 

=LET(maxNoOfItems;E16;
anchorCell;AA2;
fullWidth;2+maxNoOfItems;
leftCol;OFFSET(anchorCell#;0;-1);
currentRegion;OFFSET(leftCol;0;0;;fullWidth);
output;INDEX(SORT(currentRegion;;-1);SEQUENCE(AB23);SEQUENCE(;fullWidth));
output
)

 

bosinander_4-1637444423425.png