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

If (case) statements using metrics

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi All,

 

I'm looking to do a simple calculated field using a case-when statement, but all my fields are Metrics and I only ever get "cannot parse" errors. Is there a way to do this?

 

For context, I need to change a formula multiplier from 4 to 5 based on whether or not one input is greater or less than another. All inputs are blue (metrics), some of which come from tables and some of which are calculated fields themselves.

1 Expert replyverified_user

If (case) statements using metrics

Top Contributor
# 2
Top Contributor

Hi @Kevin B could you please post the formula in question?

 

Kind regards,

Zorin

Web analyst @ escapestudio.net

If (case) statements using metrics

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Essentially I have 2 numbers (metrics) - Target and Actual. I want to compare them and get a different output based on the comparison. Formula would be 

 

CASE WHEN (Target>Actual) THEN (280*Actual/Target) ELSE (350*Actual/Target)

If (case) statements using metrics

[ Edited ]
Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Hi Kevin, 

same problem here. Any solution by now?

Here is my easy formula; both are metrics:

 

CASE
WHEN Users>Target Users THEN "nice" ELSE "bad"
END

 

 

thank you!

If (case) statements using metrics

Follower ✭ ✭ ☆
# 5
Follower ✭ ✭ ☆

What is your data source, dimension and metric combination for this?

If (case) statements using metrics

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭

Hi Albert,

 

both metrics ('Users' and 'Target Users') out of the same Google Docs!

bests