Google Data Studio中NOT REGEXP_MATCH函数失效问题求助
I've run into this exact syntax quirk in Data Studio before—even though the official docs say NOT should work with REGEXP_MATCH, the editor sometimes chokes on it when combined with AND in a CASE statement. Here are a couple of workarounds that should get your custom field working:
1. Use a Negative Lookahead in Your Regex (Recommended)
Instead of relying on the NOT operator, rewrite the "does not match" logic directly in your regex pattern using a negative lookahead. This avoids the editor's syntax parsing issue entirely:
CASE WHEN REGEXP_MATCH(receipt,"75") AND REGEXP_MATCH(gameid, "^((?!75).)*$") THEN "0.75" END
The pattern ^((?!75).)*$ will match any string that does not contain "75" anywhere in it, which is exactly what NOT REGEXP_MATCH(gameid,"75") is supposed to do.
2. Wrap the NOT Clause in Parentheses
Sometimes the editor just needs a little help parsing the syntax correctly. Try wrapping the NOT REGEXP_MATCH part in parentheses to make the logic clearer to the parser:
CASE WHEN REGEXP_MATCH(receipt,"75") AND (NOT REGEXP_MATCH(gameid,"75")) THEN "0.75" END
This often fixes the syntax highlighting issue (where THEN turns black) and lets the field save successfully.
If All Else Fails
If neither of the above works, it might be a temporary bug in Data Studio's editor. Try these quick fixes:
- Refresh your browser tab and re-create the field
- Clear your browser cache and cookies, then restart the browser
- Test the field creation in a different browser (Chrome vs. Firefox, etc.)
内容的提问来源于stack exchange,提问作者And Row ID

