5 Replies Latest reply on Jun 7, 2016 1:46 AM by Mahfooj Khan

# Cannot solve aggregation & non-aggregated fields problem.

Hi all,

Would greatly appreciate the help here, the below calculation is giving me the classic "cannot mix aggregated and non-aggregated fields" error message.

Gross Profit % is an aggregated field i.e. SUM (Gross Profit) / SUM (Total Sales) and cannot be calculated any other way so I am happy with this part.

InReportQuarter? is a dimension and is the issue here, its calculated as follows:

Where Report Quarter is a date parameter used to flick between different periods.

How to I aggregate the second screen shot above? I have tried everything!!

Thanks,

Ray

• ###### 1. Re: Cannot solve aggregation & non-aggregated fields problem.

Resolving "Cannot mix aggregate and non-aggregate arguments" Calculation Error | Tableau Software

try this one

ins second formula you can try like this

DATETRUNC('quarter',[Order Date]), you get Q1, orQ2

and then in first formula

if (inreportquarter?)='Q1' then (grossprofit) end;

Tharashasank Davuluru

Mahfooj Khan

• ###### 2. Re: Cannot solve aggregation & non-aggregated fields problem.

is [gross profit %] a formula? if yes then please share the details of the same.

-Ashish

• ###### 3. Re: Cannot solve aggregation & non-aggregated fields problem.

Try this

Gross profit new: sum(if datetrunc('quarter',[Rptg Yr Qtr Abbrv])= [Report Quarter] then [Gross Profit] else 0 end)

Total Sales new: sum(if datetrunc('quarter',[Rptg Yr Qtr Abbrv])= [Report Quarter] then [Total Sales] else 0 end)

New Gross Profit %

[Gross profit new]/ [Total Sales new]

Let me know If this helps

Mahfooj

• ###### 4. Re: Cannot solve aggregation & non-aggregated fields problem.

Thank you so much Mahfooj, really creative thinking. Owe you a pint!

• ###### 5. Re: Cannot solve aggregation & non-aggregated fields problem.

Just mark my answer as correct If you found it helpful that's it. That will be my treat