I would like to use filter function so that when various selections are made, it filters the data accordingly even if sometimes the selection is "All" or just left blank.
I can do this for one selection using:
=FILTER(A7:A10,A7:A10=b2,A7:A10)
but doesn't seem to work when I was to use multiple selections:
=FILTER(A7:A10,(A7:A10=b2,A7:A10)*(B7:B10=b3,B7:B10))
or
=FILTER(A7:A10,(A7:A10=b2)*(B7:B10=b3),A7:A10)
=LET(data,A7:B10,crit,B2:B3,
OneOrFilter,LAMBDA(array,crit,IF(OR(crit="All",crit=""),1,array=crit)),
nf,OneOrFilter(CHOOSECOLS(data,1),INDEX(crit,1)),
lf,OneOrFilter(CHOOSECOLS(data,2),INDEX(crit,2)),
IF(AND(nf=1,lf=1),data,FILTER(data,nf*lf,"")))
i.e.
=LET(
OneOrFilter,LAMBDA(array,crit,IF(OR(crit="All",crit=""),1,array=crit)),
nf,OneOrFilter(A7:A10,B2),
lf,OneOrFilter(B7:B10,B3),
IF(AND(nf=1,lf=1),A7:B10,FILTER(A7:B10,nf*lf,"")))
OneOrFilter
function returns either 1
, if the criteria is "All" or blank, or an array of TRUE/FALSE
s, as the result of comparing a column against a criterion.1
when the requirement is to show all data. Otherwise, show the filtered data.