Regular expression with calculated field in Google Data Studio

落花浮王杯 提交于 2021-02-16 15:09:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!