AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Data Studio
1.6K members online now
1.6K members online now
Ask questions about Data Studio
Guide Me
star_border
Reply

CASE WHEN formula only returns ELSE case

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I have created a new dimension using the following formula:

 

CASE WHEN userId = "C8q2KT" THEN "001 Customer" WHEN userId = "qyuWcN" THEN "002 Customer" ELSE "Users Pending" END

 

This formula always evaluates to "Users Pending", even though I know "C8q2KT" and "qyuWcN" cases exist and are visible on the report.

 

I have tried several fixes 1) changing to single quotation 2) regex with and without wild cards 3) checking that both existing dimension UserId and the new dimension are set to text data type

 

Any other suggestions for how I can fix this?

 

Note I used a similar working formula for other reports but just can't get it to work here. Thanks

CASE WHEN formula only returns ELSE case

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

Hi Tony, I think your answer is on this page

Best regards !

CASE WHEN formula only returns ELSE case

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi Victor, I tried that too and sadly the same thing happened. I literally copied the example and just altered the variable and case names. It always evaluates to the ELSE case.

To test if it was my syntax that was wrong I even tried REGEXP_MATCH(name, '[a-zA-Z].*') - the test of cases which start with a letter. But still. No luck always goes to ELSE.

CASE WHEN formula only returns ELSE case

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Toni,

Does your custom field "userId" appears when you start to type it in the formula field ? If yes, this formula should work :

CASE WHEN (REGEXP_MATCH(userId, 'C8q2KT')) THEN "001 Customer" WHEN (REGEXP_MATCH(userId, 'qyuWcN')) THEN "002 Customer" ELSE "Users Pending" END

If not, it may that you data "userId" is not connected to Data Studio