4 Replies Latest reply on Dec 4, 2013 11:39 AM by Amy Song

# Calculated field with an aggregated function based on time

Hi there,

Trying to figure out this "can not mix aggregated and non-aggregated arguments to function" error I'm getting.

In the attatched example using superstore, I am trying to view total sales, October sales, total customers, and October customers by state.  I am able to view October sales using this calculation: iif(month([Order Date])=10,[Order Quantity],0)

I get the error when trying to use it for customers, which is an aggregated calculation: count(Customer)

I tried to use the attr on my month, but that didn't seem to work either.

Thanks!

Amy

• ###### 1. Re: Calculated field with an aggregated function based on time

Hi Amy,

Please try the below calculation for Customer Count.

Countd(If month([Order Date])=10 then Customer End) : For unique customers, will not work if the data source is excel.

Countd(If month([Order Date])=10 then Customer End) : For customer count including duplicates

• ###### 2. Re: Calculated field with an aggregated function based on time

You can resolve the error by using:

if attr(month([Order Date]))=10 then ([Customer count]) END

However, I don't see how this is any different from the Customer Count you are already displaying.

Of course, all of this would be much simpler if you just filtered for the month of October in this sheet.  Then, you'd simple drag Orders, Quantity, and Counts to their respective shelves and you'd be all set.

Also, .lndumon's advice is good.

• ###### 3. Re: Calculated field with an aggregated function based on time

Second equation typo edit.

Countd(If month([Order Date])=10 then Customer End) : For customer count including duplicates

Count(If month([Order Date])=10 then Customer End) : For customer count including duplicates

• ###### 4. Re: Calculated field with an aggregated function based on time

Thanks, that worked!