AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Data Studio
3.6K members online now
3.6K members online now
Ask questions about Data Studio
Guide Me
star_border
Reply

Problem with REGEXP_EXTRACT

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi, I am trying to use REGEXP_EXTRACT to tell the program to combine the impression devices (dimension) Android Smartphone and IPhone for a joint field named "mobile devices", etc. My problem is that I dont know how to combine those to attributes in one code.

thanks for your help

 

CASE 

WHEN REGEXP_EXTRACT(Impression Device, '(Android Smartphone), (iPhone)') THEN 'Mobile devices' 
WHEN REGEXP_EXTRACT(Impression Device, '(Desktop)') THEN 'Desktop' 
WHEN REGEXP_EXTRACT(Impression Device, '(Android Tablet), (iPad)') THEN 'Tablet' 
ELSE 'Other devices'
END

Problem with REGEXP_EXTRACT

Explorer ✭ ✭ ✭
# 2
Explorer ✭ ✭ ✭

Hi Elisa,

 

If you're just wanting to identify them with a CASE statement then I would drop the regex, as I can't see why it would be required, and this will simplify your query?

 

Ben

Re: Problem with REGEXP_EXTRACT

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi Ben,

how would then the formula look like?

Elisa

CASE
WHEN (Impression Device, '(Android Smartphone/iPhone)') THEN 'Mobile
devices'
WHEN (Impression Device, '(Desktop)') THEN 'Desktop'
WHEN (Impression Device, '(Android Tablet/iPad)') THEN 'Tablet'
ELSE 'Other devices'
END

Problem with REGEXP_EXTRACT

Explorer ✭ ✭ ✭
# 4
Explorer ✭ ✭ ✭

Hi Elisa,

 

Thinking about this again, I would maybe leave the regex in so that your code is easier to scale, how about the below without the parentheses:

 

CASE
WHEN REGEXP_MATCH(Impression Device, "Android Smartphone/iPhone") THEN "Mobile devices"
WHEN REGEXP_MATCH(Impression Device, "Desktop") THEN "Desktop"
WHEN REGEXP_MATCH(Impression Device, "Android Tablet/iPad") THEN "Tablet"
ELSE "Other devices"
END