Forum Discussion
Lambda for Getting Sums Based on Dynamic Filters
For this part: (IF(Dept = "", nofltr, INDEX(tbl, , XMATCH("Staff & Agencies Involved", hdrs)) = Dept))
One thing I forgot to mention is that the Dept value would need to be formatted for a partial text match. The context is that the data in the "Staff & Agencies Involved" column contains answers from a multi-selection choice question in MS Forms, which comes out looking something like ["Option1","Option2","Option3"]. My understanding is that FILTER() doesn't support wildcards, but some other online sources suggested something like this might work:
.....*(IF(Dept="",noflter,INDEX(tbl,,XMATCH("Staff & Agencies Involved",hdrs))=(ISNUMBER(SEARCH(Dept,Table1[Staff & Agencies Involved]))*.....
This doesn't appear to work, though. Any ideas? Your solution works great otherwise.
If wildcards are needed I'm inclined to use regex. One thing that could be simplified is removing the need to find the column where the term(s) might be located. If you're confident of the column order then the function can be simplified.