FILTER Wildcard Not Working in Excel and Google Sheets
FILTER treats *north* as literal text, not a wildcard. Use SEARCH or REGEXMATCH for a partial match, and escape * and ? in a search box.
本文目录
You typed *north* into a FILTER formula, expecting every campaign that contains “north”. In Google Sheets the formula returns #N/A, “No matches are found in FILTER evaluation.” FILTER does not interpret wildcards. The fix is to search inside each cell, not to compare the whole cell to a pattern.
Enter this campaign list in A1:C10. Type 1500 in B9 as a number, not as text. Leave A10:C10 empty.
| Campaign ID | Campaign | Leads |
|---|---|---|
| C101 | North Launch | 120 |
| C102 | Spring North | 85 |
| C103 | South Launch | 64 |
| C104 | NORTH Retargeting | 42 |
| C105 | Northwest Sale | 96 |
| C106 | Promo?2026 | 31 |
| C107 | Promo*2026 | 27 |
| C108 | 1500 | 18 |
类型 north in E2. In G2, enter:
=FILTER(A2:C10,ISNUMBER(SEARCH(E2,B2:B10)))
This returns four rows: C101, C102, C104, and C105, with lead counts of 120, 85, 42, and 96. You do not need asterisks around north. SEARCH already looks for the term anywhere in the text.
The formula works in Google Sheets and in versions of Excel that include FILTER (Microsoft 365, Excel 2021, and Excel 2024). The results below were measured in Google Sheets. Excel was not run.
Why a wildcard equality test matches nothing
=FILTER(A2:C10,B2:B10="*north*")
B2:B10="*north*" asks whether the campaign name is exactly the literal text *north*, including both asterisks. None of the sample names is that string, so every test is FALSE. In this Google Sheets file the formula returned #N/A, “No matches are found in FILTER evaluation.”
COUNTIF interprets wildcards in its criteria. XLOOKUP can too, when match mode is 2. See XLOOKUP wildcard matching 与 counting cells containing text. The = operator does neither, and FILTER has no wildcard mode of its own.
Case-sensitive partial matches
SEARCH ignores case, which is why north also caught NORTH Retargeting 与 Northwest Sale. To keep the case, use FIND.
Change E2 to North:
=FILTER(A2:C10,ISNUMBER(FIND(E2,B2:B10)))
This returns C101, C102, and C105. C104 drops out because that name is NORTH, not North.
Begins with, or ends with
A contains search is too broad when you only want names that start or end with the term. Put north back in E2.
=FILTER(A2:C10,LEFT(B2:B10,LEN(E2))=E2)
This returns C101, C104, and C105. It drops C102, Spring North. It includes Northwest Sale, because the first five characters of Northwest are North. The = comparison is not case-sensitive: LEFT of NORTH Retargeting is NORTH, and NORTH="north" was TRUE. EXACT of those two strings was FALSE.
You can also test whether SEARCH found the term at position 1:
=FILTER(A2:C10,IFERROR(SEARCH(E2,B2:B10)=1,FALSE))
That returned the same three rows. In this file, FILTER also returned those three rows when I left IFERROR off, because the #VALUE! results from SEARCH on non-matching names did not break the FILTER. I still wrap the test in IFERROR so the condition is a clean FALSE. I have not checked whether Excel FILTER accepts an error in the include array.
Ends with uses RIGHT instead of LEFT:
=FILTER(A2:C10,RIGHT(B2:B10,LEN(E2))=E2)
With north in E2, this returns only C102, Spring North, with 85 leads.
LEFT and RIGHT treat * 与 ? as ordinary characters. RIGHT(B2:B10,LEN("Promo?2026"))="Promo?2026" returned only C106, and the same test for Promo*2026 returned only C107.
An empty search box is not an empty result
Clear E2 and enter =SEARCH(E2,B2). The result is 1. SEARCH treats an empty find-text as a match at the start of any non-empty cell, including the number in B9.
On a blank cell the story changes. =SEARCH("",B10) returned #VALUE!, “Function SEARCH parameter 2 value should be non-empty.” The same message appeared when the cell was a formula that returned "".
So the original FILTER formula, with E2 cleared, returned the eight populated campaign rows, not the empty ninth row. The blank row is left out because SEARCH cannot search a blank cell, not because FILTER specially ignores blanks.
If you are building a searchable list, decide what an empty box should do.
Show a prompt until someone types a term:
=IF(E2="","Enter a search term",FILTER(A2:C10,ISNUMBER(SEARCH(E2,B2:B10))))
With E2 empty, this displays Enter a search term. With north, it returns C101, C102, C104, and C105.
I prefer this for a shared sheet. It makes the box’s purpose obvious and stops a huge range from spilling when someone clears it.
If you want the formula to display nothing instead, use "" as the empty value. That value is not a genuinely empty cell: ISBLANK of IF(E2="","",1) was FALSE when E2 was empty.
To show every row that has a campaign ID until the user types something:
=IF(E2="",FILTER(A2:C10,A2:A10<>""),FILTER(A2:C10,ISNUMBER(SEARCH(E2,B2:B10))))
Clearing E2 returned C101 through C108. north narrowed it to the same four rows as before. The A2:A10<>"" branch is what includes every populated ID when the box is empty. Do not rely on SEARCH of an empty string for that job: SEARCH already skips blank campaign names, and a row that has an ID but no name stays out.
SEARCH still treats asterisks and question marks as wildcards
SEARCH itself supports wildcards: * for any sequence, ? for one character, and ~ to escape either one.
类型 Promo?2026 in E2 and use the original contains formula. It returns both C106 and C107, because the ? matches the single character in either name, the literal question mark or the asterisk.
Promo*2026 has the same problem: the asterisk is a wildcard, so the formula returns both C106 and C107 rather than only the name that contains a star.
To find the real question mark, type Promo~?2026 in E2. The same formula then returns only C106, Promo?2026, with 31 leads. Promo~*2026 returns only C107, Promo*2026, with 27 leads. A literal tilde is escaped as ~~.
That is fine when you are typing the pattern yourself. It is a poor default for a search box used by people who do not know wildcard syntax.
Escape the term before SEARCH
=FILTER(A2:C10,ISNUMBER(SEARCH(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(E2,"~","~~"),"*","~*"),"?","~?"),B2:B10)))
Escape the tilde first, then *, then ?. If you escape the tilde last, the tildes you just inserted in front of * 与 ? get doubled again.
With this formula, Promo?2026 returns only C106, Promo*2026 returns only C107, and north still returns C101, C102, C104, and C105.
For a shared search box, I would standardize on this: case-insensitive, literal characters, automatic escaping.
FIND already treats those characters as text
FIND is case-sensitive and does not treat * 或 ? as wildcards. With Promo?2026 in E2:
=FILTER(A2:C10,ISNUMBER(FIND(E2,B2:B10)))
this returned only C106. FIND("?",B7) returned 6, the position of the question mark in Promo?2026. FIND("?",B8) was #VALUE!, and FIND("*",B8) returned 6. Use FIND when you want that literal match and you also care about case. See FIND vs SEARCH.
Numbers in the campaign column
=ISNUMBER(B9) returns TRUE; B9 is the number 1500, not text. Enter 15 in E2 and the SEARCH formula still returns C108, with 18 leads, because SEARCH converts the number to text for the comparison.
When I stored 1500 as text instead, ISNUMBER was FALSE, and the same 15 search still returned C108.
That is different from a wildcard COUNTIF. COUNTIF(B2:B10,"*15*") returned 0 while B9 was a number, and 1 after the same value was stored as text.
=FILTER(A2:C10,ISNUMBER(SEARCH(E2,B2:B10&""))) also returned C108 for 15, whether B9 was a number or text. The &"" only changes what SEARCH sees, not the value in B9.
If 1500 is formatted as 001500, the display is not what &"" produces. In this file a custom format of 000000 showed 001500, B9&"" returned 1500, and TEXT(B9,"000000") returned 001500. Store identifiers as text when the leading zeros are part of the code.
Does not contain the search term
To exclude campaigns that contain the term, wrap the test in NOT. With north in E2:
=FILTER(A2:C10,NOT(ISNUMBER(SEARCH(E2,B2:B10))))
This returns C103, C106, C107, C108, and the empty source row, five rows in all. The blank row appears because SEARCH of north in a blank cell is #VALUE!, ISNUMBER is FALSE, and NOT turns that into TRUE.
Add a check that the row has a campaign ID:
=FILTER(A2:C10,(A2:A10<>"")*NOT(ISNUMBER(SEARCH(E2,B2:B10))))
This returns the four populated rows:
| Campaign ID | Campaign | Leads |
|---|---|---|
| C103 | South Launch | 64 |
| C106 | Promo?2026 | 31 |
| C107 | Promo*2026 | 27 |
| C108 | 1500 | 18 |
For a contains search, the ID check is not what keeps a completely empty row out; SEARCH already fails on a blank campaign name. The ID check matters here, in the reversed test, and in the “show all IDs when the box is empty” branch above.
An empty search box reverses badly: SEARCH finds an empty string in every non-empty name, so NOT excludes every populated row. Guard it:
=IF(E2="","Enter a search term",FILTER(A2:C10,(A2:A10<>"")*NOT(ISNUMBER(SEARCH(E2,B2:B10)))))
Empty E2 displays Enter a search term. north returns the same four campaigns.
Either term, or both
Enter north in E2 与 launch in F2.
=FILTER(A2:C10,(ISNUMBER(SEARCH(E2,B2:B10))+ISNUMBER(SEARCH(F2,B2:B10)))>0)
This returns five rows: C101, C102, C103, C104, and C105. Adding the two conditions produces 0, 1, or 2. The >0 test keeps either kind of match. C101 contains both terms and appears once.
To require both terms, multiply the conditions instead of adding them:
=FILTER(A2:C10,ISNUMBER(SEARCH(E2,B2:B10))*ISNUMBER(SEARCH(F2,B2:B10)))
With north 与 launch, this returns only C101, North Launch, with 120 leads.
If one of the two boxes can be left empty, an unguarded OR includes every non-empty name, because SEARCH of an empty string returns 1. Disable each condition when its cell is empty:
=IF(AND(E2="",F2=""),"Enter a search term",FILTER(A2:C10,(A2:A10<>"")*((E2<>"")*ISNUMBER(SEARCH(E2,B2:B10))+(F2<>"")*ISNUMBER(SEARCH(F2,B2:B10))>0)))
| E2 | F2 | Returned campaign IDs |
|---|---|---|
| north | launch | C101, C102, C103, C104, C105 |
| north | C101, C102, C104, C105 | |
| launch | C101, C103 | |
| Enter a search term |
REGEXMATCH in Google Sheets
Sheets also has REGEXMATCH, which returns TRUE or FALSE. It is useful for alternatives, anchors, and word boundaries. It is not an Excel function.
=FILTER(A2:C10,REGEXMATCH(B2:B10&"","(?i)"&E2))
With north in E2, this returns C101, C102, C104, and C105. The (?i) flag makes the pattern case-insensitive. Without it, lowercase north matched none of the sample names, and FILTER returned #N/A, “No matches are found in FILTER evaluation.”
The &"" is not optional if the column can contain numbers. REGEXMATCH(B9,"15") returned #VALUE!, “Function REGEXMATCH parameter 1 expects text values. But ‘1500’ is a number and cannot be coerced to a text.” Wrapping FILTER around that test did not surface #VALUE!; it skipped the numeric row. REGEXMATCH(B2:B10,"15") therefore returned #N/A, no matches, and missed C108. REGEXMATCH(B2:B10&"","15") returned C108.
| Search requirement | Regular expression | Campaign IDs in this sample |
|---|---|---|
| Contains north, any case | (?i)north | C101, C102, C104, C105 |
| Begins with north | (?i)^north | C101, C104, C105 |
| Ends with north | (?i)north$ | C102 |
| Contains north or south | (?i)north|south | C101, C102, C103, C104, C105 |
| Contains north as a whole word | (?i)\bnorth\b | C101, C102, C104 |
| Contains a literal question mark | \? | C106 |
| Contains a literal asterisk | \* | C107 |
In the word-boundary formula, write the pattern as (?i)\bnorth\b inside the quoted string:
=FILTER(A2:C10,REGEXMATCH(B2:B10&"","(?i)\bnorth\b"))
This returns C101, C102, and C104, and drops C105, because Northwest has no word boundary after north.
REGEXMATCH(B2:B10&"","\?") returned only C106. REGEXMATCH(B2:B10&"","\*") returned only C107.
If E2 is an ordinary search box, do not pass it straight to REGEXMATCH. Users can type an unintended pattern or an invalid expression. Use escaped SEARCH unless you want regular expressions on purpose.
When nothing matches
Enter west coast in E2. None of the sample names contains that phrase. The basic contains formula returns #N/A in Google Sheets, “No matches are found in FILTER evaluation.” Excel’s empty FILTER result is #CALC!; see fixing the Excel #CALC! error. That Excel error was not re-measured here.
Excel FILTER takes an optional third argument for the empty result:
=FILTER(A2:C10,ISNUMBER(SEARCH(E2,B2:B10)),"No matches")
I did not run that in Excel. Do not paste it into Google Sheets. Sheets uses the third argument as another condition, not as an if-empty fallback. In this file it returned #N/A, “FILTER has mismatched range sizes. Expected row count: 9. column count: 1. Actual row count: 1, column count: 1.”
Wrap FILTER in IFNA instead:
=IFNA(FILTER(A2:C10,ISNUMBER(SEARCH(E2,B2:B10))),"No matches")
With west coast this displays No matches. With north it returns C101, C102, C104, and C105.
IFNA also hides #N/A from a range-size mistake. If results disappear after you edit a reference, temporarily remove IFNA and read the real message. For example:
=FILTER(A2:C10,ISNUMBER(SEARCH(E2,B2:B9)))
returned #N/A, “FILTER has mismatched range sizes. Expected row count: 9. column count: 1. Actual row count: 8, column count: 1.” That is a range problem, not a failed search.
A search-box formula measured in this Sheets file
If the sheet has to work in both Excel and Google Sheets, check the match count before FILTER runs, and escape the term first. This version keeps term 与 escaped as names, and it inlines the array in both SUMPRODUCT and FILTER:
=LET(
term,E2,
escaped,SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(term,"~","~~"),"*","~*"),"?","~?"),
IF(term="","Enter a search term",
IF(SUMPRODUCT((A2:A10<>"")*ISNUMBER(SEARCH(escaped,B2:B10&"")))=0,"No matches",
FILTER(A2:C10,(A2:A10<>"")*ISNUMBER(SEARCH(escaped,B2:B10&"")))
)
)
)
| Search term in E2 | Returned campaign IDs or message |
|---|---|
| north | C101, C102, C104, C105 |
| NORTH | C101, C102, C104, C105 |
| launch | C101, C103 |
| Promo?2026 | C106 |
| Promo*2026 | C107 |
| ? | C106 |
| * | C107 |
| 15 | C108 |
| west coast | No matches |
| Enter a search term |
I also tried the more compact form that assigns that array to a matches name and reuses it. In this Google Sheets file that returned #VALUE!, “The default output of this reference is a single cell in the same row but a matching value could not be found. To get the values for the entire range use the ARRAYFORMULA function.” Wrapping the assigned array in ARRAYFORMULA fixed it here, but ARRAYFORMULA is not an Excel function, so I did not use that form as the shared formula.
The formula needs an Excel version that has both FILTER and LET; I have not run it in Excel. The same empty-term, no-match, and north results also came back from an equivalent formula that does not use LET, with the SUBSTITUTE expression written out twice.
For a one-off search, the short ISNUMBER(SEARCH()) formula is enough. Use the longer one when the box is a permanent part of a shared sheet, so people can type ordinary text without learning wildcard syntax.