如何在Looker Studio中使用“但不是”条件来分组事物?

huangapple go评论82阅读模式
英文:

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 NOTwill 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
英文:

<!-- language-all: js -->

You may try:

CASE
WHEN REGEXP_CONTAINS(URL, &quot;category1/$&quot;) THEN &quot;category1 folder&quot; 
WHEN REGEXP_CONTAINS(URL, &quot;category1/.+&quot;) THEN &quot;category1 url&quot;
END

如何在Looker Studio中使用“但不是”条件来分组事物?

huangapple
  • 本文由 发表于 2023年7月13日 22:20:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76680434.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定