?#?#?#?# Aggregate error

texasalynn

Well-known Member
Joined
May 19, 2002
Messages
8,458
I have this query but can not get LIT Description field to work. I have looked it up and down, inside and out but can not find where it is not liking it?

SELECT [Customer Invoice].[G/L ACCT#], Sum([Customer Invoice].[SUBTOTAL AMOUNT]) AS [SumOfSUBTOTAL AMOUNT], Sum([Customer Invoice].[TAX AMOUNT]) AS [SumOfTAX AMOUNT], Sum([Customer Invoice].[TOTAL AMOUNT]) AS [SumOfTOTAL AMOUNT], IIf([type]="Recycle","CARDBOARD REV","# OF HAULS=" & Count([HDIDDT])) AS [LIT Descripiton], [Customer Invoice].[LOCATION/STORE#], [Customer Invoice].[LOCATION ADDRESS]
FROM [Customer Invoice]
GROUP BY [Customer Invoice].[G/L ACCT#], [Customer Invoice].[LOCATION/STORE#], [Customer Invoice].[LOCATION ADDRESS];

Can someone please direct me
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
What's the full actual error message?
 
Upvote 0
"you tried to execute a query that does not include the specified expression IIf([type]="Recycle","CARDBOARD REV","# OF HAULS=" & Count([HDIDDT])) as part of an aggregate function"
 
Upvote 0
Hi Lynn
I haven't tested this so I'm not sure if it will work but try changing 'Group By' to 'Expression' under the LIT Description field.
HTH, Andrew :)
 
Upvote 0
Yes I had that and that's what gives the error. I know it's because of the group by but I don't know why it is not working. Any other thoughts?
 
Upvote 0
Hi Lynn

I still haven't tested this (in other words I haven't replicated the problem) but how about splitting the text and numerical values into 2 different columns? If the type = Recycle then you could set the value to 0, instead of doing the count. Does it make any difference?

Just a thought
Andrew
 
Upvote 0
That Iif function coupled with a Count function can't work in an aggregate query. YOu may try using a subquery to obtain the count.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top