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?
"(?s).*(johnson?).*"
and"(?s).*(occonor?).*"
– Wiktor Stribiżewtags_name
parameter is fed properly. You can check it by replacing the result in the ELSE close. Instead ofELSE "undefined"
, tryELSE CONCAT("The tags_name is: ", tags_name)
. – colourCoder