Reputation: 609
I'm using Google data studio and I need to group some data.
I have a column with some codes (3 Letters words) and I want to group all codes beginning with A
and for the others I want to keep the value.
I did something like this but the Else
clause doesn't work.
CASE
WHEN NOT REGEXP_MATCH(Codes, '[A]*') THEN "Others"
ELSE Codes
END
How can I keep the value of the field in a certain case ?
Upvotes: 1
Views: 245
Reputation: 6471
Either of the following REGEXP_REPLACE
Calculated Fields will do the trick where ^
indicates the beginning of the value:
REGEXP_REPLACE(Codes, "^([B-Z].*)", "Others")
REGEXP_REPLACE(Codes, "^(A.*)", "Others")
Google Data Studio Report and a GIF to demonstrate:
Upvotes: 2