4 Replies Latest reply on Jan 9, 2019 8:44 PM by Naveen B

# Cannot Mix Aggregate and Non- Aggregate Comparisons or results in IF expressions

Hi all,

Can someone troubleshoot this calculated field for me? I am trying to get the Orders sold for the previous week using this calculated formula but this error shows up

Cannot Mix Aggregate and Non- Aggregate Comparisons or results in IF expressions

below is the calculated field I used:

IF DATETRUNC('week',[Order Created At])=DATETRUNC('week',DATEADD('week',-1,TODAY()))

THEN [Orders bCancellation]

END

Thank you!

• ###### 1. Re: Cannot Mix Aggregate and Non- Aggregate Comparisons or results in IF expressions

IF ATTR(DATETRUNC('week',[Order Created At]))=ATTR(DATETRUNC('week',DATEADD('week',-1,TODAY())))

THEN [Orders bCancellation]

END

Change your calculation to above hope this helps.

Plz mark this answer as correct or helpful to close the thread

BR,

NB

• ###### 2. Re: Cannot Mix Aggregate and Non- Aggregate Comparisons or results in IF expressions

Hello,

The calculation was valid but when I tried to put it into the sheet , there were no data appearing in its column.

• ###### 3. Re: Cannot Mix Aggregate and Non- Aggregate Comparisons or results in IF expressions

We need to understand more about the structure of your data in order to get it working.  From a logic point of view it's fine, but what does the data look like ? Do you have some sample/dummy data that you can provide ?

• ###### 4. Re: Cannot Mix Aggregate and Non- Aggregate Comparisons or results in IF expressions

HI Vicky,

Which means you will be having one to many relationship as Chris McClellan said provide the sample data so that it will be helpful for us to solve the problem.

BR,

NB