Aggregate Function

Kully121

New Member
Joined
Sep 21, 2004
Messages
44
Hi,

I'm trying to get an average of 3 weeks (all number fields) but keep getting the group by aggregate function error

Formula as below

Week Four: IIf([Week 4] Is Null,0,Avg([Week 1]+[Week 2]+[Week 3]))

Any ideas?

Cheers,

Kully121
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Can you post the full SQL for this query? Click View -> SQL View to get to it.
Andrew :)
 
Upvote 0
SELECT [A - Pubfolio Volumes].[TPD Product Code Calendar day], [A - Pubfolio Volumes].[Week 1], [A - Pubfolio Volumes].[Week 2], [A - Pubfolio Volumes].[Week 3], IIf([Week 4] Is Null,0,Avg([Week 1]+[Week 2]+[Week 3])) AS [Week Four]
FROM [A - Pubfolio Volumes]
GROUP BY [A - Pubfolio Volumes].[TPD Product Code Calendar day], [A - Pubfolio Volumes].[Week 1], [A - Pubfolio Volumes].[Week 2], [A - Pubfolio Volumes].[Week 3];
 
Upvote 0
Hi Kully, try this :

SELECT [A - Pubfolio Volumes].[TPD Product Code Calendar day], Sum([A - Pubfolio Volumes].[Week 1]) AS [SumOfWeek 1], Sum([A - Pubfolio Volumes].[Week 2]) AS [SumOfWeek 2], Sum([A - Pubfolio Volumes].[Week 3]) AS [SumOfWeek 3], Sum([A - Pubfolio Volumes].[Week 4]) AS [SumOfWeek 4], IIf(Sum([Week 4]) Is Null,0,(Sum([Week 1])+Sum([Week 2])+Sum([Week 3]))/3) AS [Week Four]
FROM [A - Pubfolio Volumes]
GROUP BY [A - Pubfolio Volumes].[TPD Product Code Calendar day];

HTH, Andrew :)
 
Upvote 0

Forum statistics

Threads
1,221,904
Messages
6,162,744
Members
451,785
Latest member
DanielCorn

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