Forum Discussion
Power Hely
Mar 26, 2023Copper Contributor
Dynamic spill filtered based on other spill
Hello: I am trying to help my sales department come up with a dynamic sheet for rep group presentations. All data is stored in one Master Data table. I have Column A working as =SORT(UNIQUE(FIL...
PeterBartholomew1
Mar 27, 2023Silver Contributor
There is a catch. The products associated with each account form a list, and so the table you are trying to create is a nested array. Because of limitations build into Excel to retain backward compatibility, this is not properly supported. The workaround is to use REDUCE and built the array step by step using VSTACK.
=LET(
account, UNIQUE(FILTER(MasterData[Account Name], MasterData[Rep] = SelectRep)),
products, REDUCE("", account,
LAMBDA(list, ac,
VSTACK(list, TRANSPOSE(FILTER(MasterData[Product], MasterData[Account Name] = ac)))
)
),
HSTACK(account, IFNA(DROP(products, 1), ""))
)
It is possible to make the worksheet formula more readable by using a further Lambda function to return the lists of products using
= LET(
account, UNIQUE(FILTER(MasterData[Account Name], MasterData[Rep] = SelectRep)),
products, MultipleFilterλ(MasterData[Product], MasterData[Account Name], account),
HSTACK(account, IFNA(DROP(products, 1), ""))
)
but the simplification is achieved at the expense of having to define a further Lambda function MultipleFilterλ
= LAMBDA(products, accounts, selectedACs,
REDUCE("", selectedACs,
LAMBDA(list, ac, VSTACK(list, TRANSPOSE(FILTER(products, accounts = ac)))
)
)
Power Hely
Mar 27, 2023Copper Contributor
PeterBartholomew1 this is incredible! And reduces me to one spill formula instead of two. I'll need to do some reading to understand it, as VSTACK, HSTACK, REDUCE, and IFNA are new to me, but it works perfectly. I greatly appreciate you, both for solving my problem and helping me learn more about how to create better dynamic array functions!