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?
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)
^^ ^^