2 Replies Latest reply on Feb 22, 2012 10:08 AM by seanoliver

# How to get around the non-aggregate/aggreate mix in an IF statement

I have several categories of products and I need to calculate metrics using different criteria for each.  For example, I calculate the metric for Cat Toys like this:

(sum([QTD Actuals])/sum([Full Quarter Target Growth]))*.3

and the statement looks like:

IF [Product Category]= "Cat Toys" THEN

(sum([QTD Actuals])/sum([Full Quarter Target Growth]))*.3

ELSEIF [Product Category]= "Dog Toys" THEN

(sum([QTD Actuals])/sum([Full Quarter Target Growth]))*.5

END

This calcuation yields the 'cannot mix aggregate and non-aggregate comparisons or results' error.  What is the best way to handle this error?

Thanks!

• ###### 1. Re: How to get around the non-aggregate/aggreate mix in an IF statement

Hi Sean,

You can pass this calculation by changing the formula to look like the following:

IF attr([Product Category])= "Cat Toys" THEN

(sum([QTD Actuals])/sum([Full Quarter Target Growth]))*.3

ELSEIF attr([Product Category])= "Dog Toys" THEN

(sum([QTD Actuals])/sum([Full Quarter Target Growth]))*.5

END

Hope this helps!

-Tracy

• ###### 2. Re: How to get around the non-aggregate/aggreate mix in an IF statement

Perfect!  Thank you!