1
votes

I need to create a calculate field with this code :

CASE [dimension]
    WHEN 'case1' then SUM([col1])/SUM([col2])
    WHEN 'case2' then SUM([col1])/SUM([col2])
    WHEN  'case3' then SUM([col1])/SUM([col2])
ELSE 
    SUM([col1])/SUM([col3])
END

Error ." cannot mix aggregate and non-aggregate comparisons or results in 'case' expression ".

Please your help .Thanks you!

1

1 Answers

1
votes

You have to wrap [dimension] with aggregate function:

CASE MIN([dimension])
    WHEN 'case1' then SUM([col1])/SUM([col2])
    WHEN 'case2' then SUM([col1])/SUM([col2])
    WHEN  'case3' then SUM([col1])/SUM([col2])
    ELSE SUM([col1])/SUM([col3])
END

or add to GROUP BY ..., [dimension]