问题
I have the following calculated field but It doesn't work :
sum(CASE WHEN REGEXP_MATCH(url, 'foo') THEN 1 ELSE 0 END)
My goal is to sum all the url containing the word 'foo'. Does it make sense ? Where is my mistake ?
Thanks
回答1:
You need to use .*foo.*
since REGEXP_MATCH requires a full string match:
REGEXP_MATCH
attempts to match the entire string contained in field_expression.
Use
sum(CASE WHEN REGEXP_MATCH(url, '.*foo.*') THEN 1 ELSE 0 END)
^^ ^^
来源:https://stackoverflow.com/questions/41611288/regular-expression-with-calculated-field-in-google-data-studio