0
votes

I try to generate better reports in Google Data Studio. So I started using custom fields with regular expressions, which do not work like expected.

Given for example a custom field "city" with the value "I love Berlin" in it i created this statement:

CASE
  WHEN REGEXP_MATCH(city,".*Berlin.*") THEN "Berlin"         
  ELSE "Other"
END

My expected result would be a match with a returned "Berlin", but I get "Other" instead.

I tried a few different things without positive results.

2

2 Answers

1
votes

Just tested it out, and the CASE Statement provided in the question works as expected. You could have a look at adding a (Capturing Group) as well as adding a Case Insensitive flag (?i) to see if that does the trick:

CASE
  WHEN REGEXP_MATCH(city, ".*(?i)(Berlin).*") THEN "Berlin"
  ELSE "Other"
END

Google Data Studio Report and a GIF to elaborate:

0
votes

It seems like Regexp functions can't be used with the Postgres live connector (maybe MySQL as well). I solved my problem using data extraction for the fields I needed to do regex stuff on and included the created diagrams to my report which is connected to the live connector as well.