I have a tab with dynamic lists + headers across multiple columns. On a separate tab, my users can pick entries from that dynamic list (col E), and enter quantities for work recorded (col B). In col (F), I have a selective list of those headers. In col G, I want to be able to lookup the user entries (E) in the dynamic lists, return the column header, and sum B if that matches an entry in the transposed list of headers (F). And I of course prefer to use some kind of arrayformula or lambda function to make this happen.
It sounds relatively simple, but I cannot figure out how to make the formula work. It seems like some kind of nested BYROW would be the way to go. For each row in F, check E and then SUMIF H. But I can't get the logic right. I've tried QUERY, nested QUERYs, XLOOKUPS, REGEXMATCH, and more. I've also created another tab where I breakdown each item in the dynamic lists with their matching header in the adjacent column, thinking this might help with lookups.
Here's a sample of my sheet to play with. https://docs.google.com/spreadsheets/d/1BdlIb9FJ4lP306qtdMNKDSG_47jJv45DIaZphZTvl-k/edit?usp=sharing
Thanks in advance.
Use map()
, filter()
and match()
, like this:
=map(F2:F, lambda(cat,
if(cat = "", iferror(ø),
ifna(sum(filter(B2:B,
match(E2:E,
filter(Map!A2:A, Map!B2:B = cat),
0
)
)))
)
))
See map(), filter(), match() and the sample spreadsheet.