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

Data Studio CASE WHEN syntax error (Invalid formula.)

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi all,

 

I'm trying to use a CASE WHEN Formula in data Studio but it doesn't work. Basically I'd like to add a score related to the number of leads I'm generating.

 

The formula is: CASE WHEN Leads (form) > 2 THEN "good" ELSE "bad" END

 

"Leads (form)" is a GA metric set in my account. Even if I correct the formula syntax, how can I display in Data Studio an "insight" that shows me "good" or "bad" if the number of leads rises or falls?

 

 

Thanks for your support

Pierluigi 

1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Pierluigi V
June

Data Studio CASE WHEN syntax error (Invalid formula.)

Follower ✭ ✭ ☆
# 2
Follower ✭ ✭ ☆

Hi Pierluigi,

 

as you can read here, "[...] CASE statement does not allow you to mix metrics with dimensions in its WHEN, THEN, and ELSE clauses.".

 

Since you have a metric in you WHEN condition, you also need to return a metric in your THEN / ELSE results.

 

Replace "good" by 1 and "bad" by 0.

 

CASE WHEN Leads (form) > 2 THEN 1 ELSE 0 END

 

Good luck!

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Pierluigi V
June

Data Studio CASE WHEN syntax error (Invalid formula.)

Follower ✭ ✭ ☆
# 2
Follower ✭ ✭ ☆

Hi Pierluigi,

 

as you can read here, "[...] CASE statement does not allow you to mix metrics with dimensions in its WHEN, THEN, and ELSE clauses.".

 

Since you have a metric in you WHEN condition, you also need to return a metric in your THEN / ELSE results.

 

Replace "good" by 1 and "bad" by 0.

 

CASE WHEN Leads (form) > 2 THEN 1 ELSE 0 END

 

Good luck!

Data Studio CASE WHEN syntax error (Invalid formula.)

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Thank you very much Tom. The formula works. 

 

Is there any chance to add in

Data Studio CASE WHEN syntax error (Invalid formula.)

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Hi Tom,

 

thank you very much. The formula works fine Smiley Wink In your experience, is there any chance to add in Data Studio an automated insight? For instance something like that: if my CTR is below a certain level there will be an alert showing "bad". In other words, something that can display "text" if a certain condition occurs

 

Thanks for your precious support

 

Data Studio CASE WHEN syntax error (Invalid formula.)

Follower ✭ ✭ ☆
# 5
Follower ✭ ✭ ☆

Hi Pierluigi,

 

I'm glad it works for you.

 

What you're referring to is currently not possible in Data Studio, but I'm pretty sure we'll see Conditional Formatting in the future, and, if we're lucky, also some kind off Actions to make the reports more dynamic.

 

There's a feature request on the Issue Tracker that requests something along the lines. Everybody can vote for the feature to be implemented by clicking on the ★ next to the title of the issue.

 

Hope that helps.