Excel FILTER function: Filter based on an array of criteria

Anonymous
2021-08-28T04:28:52+00:00

Summary: I can use the FILTER function to filter based on the specific criteria I enumerate in the formula. But if my list of criteria is long, I'd rather pull them out of the formula, list them as an array (i.e., a column of criteria), and ask Excel to filter based on that list. How do I do this?

**************

Suppose I have the follow data table on the left of the screenshot below, and the desired output on the right. Here, for each fruit, I want a horizontal listing of the sizes in which it is available.

I can achieve this as follows:

  1. In cell F3, insert the formula =SORT(UNIQUE(A3:A101). This formula can be seen in the screenshot (I go to A101 in case I have a long list of fruits).
  2. In cell G3, insert the following formula, which more than accounts for the different sizes seen in Column B (SML,MED, LG, XLG, HUGE):
    =TRANSPOSE(SORT(UNIQUE(FILTER($B$3:$B$101,(($B$3:$B$101="SML")+($B$3:$B$101="MED")+($B$3:$B$101="LG")+($B$3:$B$101="XLG")+($B$3:$B$101="HUGE"))*($A$3:$A$101=$F3),""))))
  3. Drag the formula in G3 downward to G8.

But as you can see from Column D, the list of possible size descriptions is prodigious, and I don't want to have to list all of them in the formula, since that would make it unwieldy. Thus I'd instead like to filter based on the array of sizes listed in Column D. I tried the following, in which I asked Excel to filter based on the values in B2:B100 equalling whatever values are in D2:D100, but it didn't work:

=TRANSPOSE(SORT(UNIQUE(FILTER($B$3:$B$1001,(($B$3:$B$101=$D3:$D101)*($A$3:$A$101=$F3)),""))))

And neither did this:

=TRANSPOSE(SORT(UNIQUE(FILTER($B$3:$B$101, ISNUMBER(SEARCH($B$3:$B$101,$D$3:$D$101)*($A$3:$A$101=$F3))))))

How would I do this?

Microsoft 365 and Office | Excel | For home | MacOS

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Anonymous
    2021-08-28T05:30:35+00:00

    A shorter formula for cell G3:

    =IFERROR(TRANSPOSE(FILTER($D$3:$D$16,COUNTIFS($B$3:$B$11,$D$3:$D$16,$A$3:$A$11,F3))),"")

    Regards

    Amit Tandon

    www.excelanytime.com

    4 people found this answer helpful.
    0 comments No comments
Answer accepted by question author
  1. Anonymous
    2021-08-28T05:26:47+00:00

    Formula in cell F3:

    =SORT(UNIQUE(FILTER(A4:A15,A4:A15<>"")))

    Formula in cell G3 to be copied down:

    =IFERROR(TRANSPOSE(FILTER($D$3:$D$16,ISNUMBER(MATCH($D$3:$D$16,FILTER($B$3:$B$11,$A$3:$A$11=F3),0)))),"")

    Regards

    Amit Tandon

    www.excelanytime.com

    2 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more