I've been trying to use REGEXP_MATCH
to create a custom field in Google Data Studio but it's not working as expected.
Example of the data I'm using it on (this is how the data is formatted in the tags_name
field:
{construction,po-johnson,po-james}
{construction,po-sandy,po-occonor}
The objective is to check if a certain name exists, then create a new label.
Here's the code I'm trying (tags_name is the field name where the original text string exists):
CASE
WHEN REGEXP_MATCH(tags_name, ".*(johnson?).*") THEN "Marc Johnson"
WHEN REGEXP_MATCH(tags_name, ".*(occonor?).*") THEN "Sam Occonor"
ELSE "undefined"
END
Is this happening due to the presence of the curly brackets/commas/hyphens?
I've tried to reproduce the error in Google Data Studio based on your problem statement. Everything worked exactly as expected though.
I've entered your input (and a few other expressions for confirmation) in the tags_name
field and placed your REGEXP_MATCH
function into another field:
Here is the result:
Is this the result you expected?
Is there still an issue? If so, you could edit your question and add corresponding screenshots.