创建新的计算字段-Google Data Studio中的广告系列类型

时间:2018-08-22 09:52:43

标签: google-adwords google-data-studio

我试图在Google Data Studio中创建计算字段。我想详细了解我的广告系列类型。默认值为“仅显示”,“仅搜索”或“购物”。我想添加其他选项,例如:基于函数REGEXP_MATCH和广告系列名称的GMAIL或Youtube。这是代码,这是我编写的代码:

CASE
WHEN Campaign type IN ("Display Only") AND NOT REGEXP_MATCH(Campaign, "(?i).*[REM].*") THEN "Display"
WHEN Campaign type IN ("Display Only") AND REGEXP_MATCH(Campaign, "(?i).*[REM].*") THEN "Display - remarketing"
WHEN Campaign type IN ("Search Only") AND NOT REGEXP_MATCH(Campaign, "(?i).*[GSN].*") THEN "Search"
WHEN Campaign type IN ("Search Only") AND REGEXP_MATCH(Campaign, "(?i).*[GSN].*") THEN "Search"
WHEN Campaign type IN ("Shopping") THEN "Reklama produktowa"
WHEN Campaign type IN ("Display Only") AND REGEXP_MATCH(Campaign, "(?i).*[YT].*") THEN "Display - Youtube"
WHEN Campaign type IN ("Display Only") AND REGEXP_MATCH(Campaign, "(?i).*[GMAIL].*") THEN "Display - Gmail"
END

1 个答案:

答案 0 :(得分:0)

我不是正则表达式大师,您还没有描述所得到的错误,但是我猜可能是由方括号引起的错误?

CASE
WHEN Campaign type IN ("Display Only") AND NOT REGEXP_MATCH(Campaign, "(?i).*REM.*") THEN "Display"
WHEN Campaign type IN ("Display Only") AND REGEXP_MATCH(Campaign, "(?i).*REM.*") THEN "Display - remarketing"
WHEN Campaign type IN ("Search Only") AND NOT REGEXP_MATCH(Campaign, "(?i).*GSN.*") THEN "Search"
WHEN Campaign type IN ("Search Only") AND REGEXP_MATCH(Campaign, "(?i).*GSN.*") THEN "Search"
WHEN Campaign type IN ("Shopping") THEN "Reklama produktowa"
WHEN Campaign type IN ("Display Only") AND REGEXP_MATCH(Campaign, "(?i).*YT.*") THEN "Display - Youtube"
WHEN Campaign type IN ("Display Only") AND REGEXP_MATCH(Campaign, "(?i).*GMAIL.*") THEN "Display - Gmail"
END