0
votes

I trying to create calculation field in Google Data Studio. I want to recognize in detail my campaign type. Default It's "Display Only", "Search Only" or "Shopping". I'm interested to add other options, like: GMAIL or Youtube based on function REGEXP_MATCH and name of my campaigns. This is the code, This is the code which I wrote:

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

1 Answers

0
votes

I'm not a regex master and you haven't described the error you're getting but I'm guessing an error might be caused by the square brackets?

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