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.7K members online now
1.7K members online now
Ask questions about Data Studio
Guide Me
star_border
Reply

Conditional Case Statement with Dimensions and Metrics

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello,

I created a filter element for my custom dimension "App Version" and now I want to add a conditional case statement to this element which then applies to all my data on the page. This is the conditional logic on the filter which I have so far but it gives me an error:

 

CASE WHEN (AppVersion) = "5.3" THEN (User)*0.8 END //uplift all user counts on the page with a factor of 0.8

 

App Version = dimension

User = metric

 

Does anybody know a good workaround since I am using both dimensions and metrics in this statement?

Thanks!

Conditional Case Statement with Dimensions and Metrics

Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

If you convert your statement into 

 

Sum(CASE WHEN (AppVersion) = "5.3" THEN 0.8 END)* user

 

Then it should work, according to Google's document 

 

Good luck

Re: Conditional Case Statement with Dimensions and Metrics

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

 

Hi Jie L,

 

Thanks so much for helping here. I tried using your formula, but it still gives me an error. See screenshot.

Would you know what the issue may be?

 

app-version.PNG

 

 

Conditional Case Statement with Dimensions and Metrics

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Try change the double quote to single quote, i.e., "5.3" to '5.3'

Re: Conditional Case Statement with Dimensions and Metrics

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

unfortunately, same error... Smiley Happy

 error.PNG

 

Conditional Case Statement with Dimensions and Metrics

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Try create another calculated column, in there call the you test app and do the multiplication with users. That two step approach works for us. Good luck!

Re: Conditional Case Statement with Dimensions and Metrics

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭

Hi Jie,

 

So, just want to make sure if this is what you mean:

 

1. Custom metric "App Version 1": SUM(CASE WHEN (App Version) = '5.3' THEN (App Version 2) END)

2. Custom metric "App Version 2: (Users)*0.8

 

This way does not work, but I think we are close. Please advise, Jie.

-Thanks

Conditional Case Statement with Dimensions and Metrics

Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭

1. Custom metric "AppVersion1": SUM(CASE WHEN (App Version) = '5.3' THEN 0.8 END)

2. Custom metric "AppVersion2: (Users)*AppVersion1