Curious, why this Metric definition will not work ...
# gooddata-cloud
d
Curious, why this Metric definition will not work as a view by of Date
Copy code
SELECT SUM(
  CASE WHEN {label/price_adjustment_type} = "Fixed" 
  THEN 1 
  END )
and this metric does work
Copy code
SELECT count({label/case_interaction_id} )
WHERE{label/price_adjustment_type} = "Fixed"
What happens with the first one is that it gets classified as an unrelated data item when I choose Date as a "view by"
m
The first metric, you’re using the
SUM
function along with a
CASE
statement. But there’s no explicit filter for the “Fixed” condition, so even when the condition is not met (when
price_adjustment_type
is not “Fixed”), you’re still adding a value of 0 to the sum. This could result in inconsistent behaviour when used in a “view by” context when dealing with dates. To make the first metric more consistent with the second metric and potentially avoid the issue you’re running in to, you can modify it like this:
Copy code
SELECT SUM(
  CASE WHEN {label/price_adjustment_type} = "Fixed" 
  THEN 1 
  ELSE 0
  END )
d
@Michael Ullock it doesn't matter if I put the THEN 1 ELSE 0 END. I tried it both ways already
@Michael Ullock any thoughts?