A. Ecrubit
A. Ecrubit

Reputation: 609

Data Studio : calculated fields show current value

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

Answers (1)

Nimantha
Nimantha

Reputation: 6471

Either of the following REGEXP_REPLACE Calculated Fields will do the trick where ^ indicates the beginning of the value:

1) Others = Begins with B to Z:

REGEXP_REPLACE(Codes, "^([B-Z].*)", "Others")

2) Others = Begins with A:

REGEXP_REPLACE(Codes, "^(A.*)", "Others")

Google Data Studio Report and a GIF to demonstrate:

Upvotes: 2

Related Questions