“包含"时如何创建案例? [英] How to create CASE WHEN "contains"?
本文介绍了“包含"时如何创建案例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在Source
中搜索姓名?
Is there a possibility to search for names in Source
?
CASE
WHEN Source="facebook_instagram" OR Source="facebook.com" OR Source="m.facebook.com" OR Source="instagram.com" OR Source="instagram" OR Source="l.facebook.com" OR Source="lm.facebook.com" OR Source="facebook" OR Source="de-de.facebook.com" THEN "Social"
ELSE "Sonstige"
END
是否有一种方法可以选择所有facebook
源而不列出它们?
Is there a way to select all facebook
sources, without listing them?
推荐答案
可以使用 CASE
语句中的> REGEXP_MATCH
函数;无论字符串以(^
)开头,文本(.*
)之前,文本(.*
)之后还是它以($
)结尾的内容:
It can be achieved using the REGEXP_MATCH
function within a CASE
statement; the RegEx below looks for facebook
or (|
) instagram
regardless of what the string starts with (^
), what comes before the text (.*
), after the text (.*
) or what it ends with ($
):
CASE
WHEN REGEXP_MATCH(Source, "^.*(facebook|instagram).*$") THEN "Social"
ELSE "Sonstige"
END
Google Data Studio报告和一个详细的GIF :
Google Data Studio Report and a GIF to elaborate:
这篇关于“包含"时如何创建案例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文