英文:
How to group things in Looker Studio with "but not" condition?
问题
在Looker Studio中,我有两种类型的URL,我想要对它们进行分组。这些URL分为类别和类似文章的类型:
https://example.com/category1/
https://example.com/category1/article_abc
https://example.com/category2/
https://example.com/category2/article_xyz
我考虑在CASE语句中使用以下表达式:
CASE
WHEN URL以"category1/"结尾 THEN "category1文件夹"
WHEN URL包含"category1"但不以"category1/"结尾 THEN "category1 URL"
END
但我相当确定,带有"BUT NOT"的部分将无法正常工作。正确的方法是什么?我也许应该使用REGEX_MATCH
吗?像这样:
CASE
WHEN REGEXP_MATCH(URL,"category1/$") THEN "category1文件夹"
WHEN REGEXP_MATCH(URL,"category1/.+?") THEN "category1 URL"
END
英文:
In Looker Studio I have two types of urls, which I want to group. URLs are categories and articles looking like:
https://example.com/category1/
https://example.com/category1/article_abc
https://example.com/category2/
https://example.com/category2/article_xyz
I thought about using in the CASE a kind of the following expression:
CASE
WHEN URL ENDS_WITH "category1/" THEN "category1 folder"
WHEN URL COMTAINS "category1" BUT NOT ENDS_WITH "category1/" THEN "category1 url"
END
But I'm pretty sure, that this part with BUT NOT
will not work. What is the right way? Should I maybe make USE of REGEX_MATCH
? Like
CASE
WHEN REGEXP_MATCH(URL, "category1\/$") THEN "category1 folder"
WHEN REGEXP_MATCH(URL, "category1\/.+?") THEN "category1 url"
END
答案1
得分: 1
<!-- language-all: js -->
*你可以尝试:*
CASE
WHEN REGEXP_CONTAINS(URL, "category1/$") THEN "category1 文件夹"
WHEN REGEXP_CONTAINS(URL, "category1/.+") THEN "category1 网址"
END
[![输入图像说明][1]][1]
[1]: https://i.stack.imgur.com/7yfCm.png
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论