Explanation
This formula relies on the FILTER function to retrieve data based on a logical test . The array argument is provided as B5:D15, which contains all of the data without headers. The include argument is an expression based on the EXACT function:
EXACT(B5:B15,"RED")
The EXACT function compares two text strings in a case-sensitive manner. If the two strings are exactly the same, EXACT returns TRUE. If the two strings are not exactly the same, EXACT returns FALSE. Since we are giving EXACT a range with 11 values as the first argument, and the string “RED” as the second, EXACT returns an array with 11 results like this:
{FALSE;FALSE;FALSE;TRUE;FALSE;FALSE;TRUE;FALSE;FALSE;FALSE;TRUE}
Notice the position of TRUE values in this array corresponds to the rows where the color is “RED”.
This array returned directly to the FILTER function as the include argument. FILTER uses the array to filter the range B5:D15, and returns the three rows where the color is “RED”. Rows where the color is “Red” are not included.
Partial match
To run an exact match with FILTER based on a partial match, see the example explained here .
Dynamic Array Formulas are available in Office 365 only.
Explanation
The FILTER function can filter data using a logical expression provided as the include argument. In this example, this argument is created with an expression that uses the ISNUMBER and MATCH functions like this:
=ISNUMBER(MATCH(color,list,0))
MATCH is configured to look for each color in C5:C15 inside the smaller range J5:J7. The MATCH function returns an array like this:
{1;#N/A;#N/A;#N/A;2;3;2;#N/A;#N/A;#N/A;3}
Notice numbers correspond to the position of “found” colors (either “red”, “blue”, or “black”), and errors correspond to rows where a target color was not found. To force a result of TRUE or FALSE, this array goes into the ISNUMBER function, which returns:
{TRUE;FALSE;FALSE;FALSE;TRUE;TRUE;TRUE;FALSE;FALSE;FALSE;TRUE}
The array above is delivered to the FILTER function as the include argument, and FILTER returns only rows that correspond to a TRUE value.
With hardcoded values
The example above is created with cell references, where target colors are entered in the range J5:J7. However, by using an array constant , you can hardcode values into the formula like this with the same result:
=FILTER(data,ISNUMBER(MATCH(color,{"red","blue","black"},0)),"No data")
Dynamic Array Formulas are available in Office 365 only.