Wrox Programmer Forums Aggregate Function
 |
 Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
 Welcome to the p2p.wrox.com Forums. You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com

December 4th, 2005, 04:16 PM
 Adamcg Registered User Join Date: Dec 2005 Posts: 2 Thanks: 0 Thanked 0 Times in 0 Posts
Aggregate Function

What i am aattempting to do is create an aggregate function that multiplies together all of the results from a query. For example, if the query contained 1,2 and 5, the aggregate function would return 10. It would not seem to be difficult to do this, but I am a new Access user, and am having trouble with these aggregate functions. Please help me if you know how.

December 4th, 2005, 05:40 PM
 bjackman Authorized User Join Date: Nov 2003 Posts: 43 Thanks: 0 Thanked 0 Times in 0 Posts

Need a little more info on what your trying to accomplish. if you're wanting to multiply all the values from a query against each other, you're probably gonna have to write some sort of custom function that loops through the results.

December 4th, 2005, 08:04 PM
 Adamcg Registered User Join Date: Dec 2005 Posts: 2 Thanks: 0 Thanked 0 Times in 0 Posts

I was thinking that was what would be necassary.

I have a table of monthly return data for an investment. What the function will do is multiply together a compound return for the period in question. If i knew the VBA for the sum function, it would be a simple matter of switching the +'s to *'s.

Below would be a specific example:

Date Return
Oct 05 1.1%
Nov 05 1.3%
Dec 05 2.5%

If I specified a three month time period through a form (i can do this part), I might get data like above. What I would wantr to see is the compound return, which would be 1.011(1+the return value)times 1.013 times 1.025, or 1.0497 as a totak number. This data item indicates a that there is a 4.97% return over that time period. Again, so easy in Excel, so hard in Access. Thanks for helping out.

December 5th, 2005, 09:24 AM
 mmcdonal Friend of Wrox Join Date: Mar 2004 Posts: 3,069 Thanks: 0 Thanked 10 Times in 10 Posts

Can you write out the formula that you would have used in Excel that you want to duplicate in Access?

Thanks,

mmcdonal

 Similar Threads Thread Thread Starter Forum Replies Last Post aggregate function polofson BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 August 14th, 2007 01:29 PM Using AVG aggregate function with decimal elygp SQL Server 2000 2 May 7th, 2007 09:04 PM Aggregate function MAX creating problem..? Manu SQL Language 4 May 30th, 2006 04:41 AM Aggregate Function MAX, SUM Manu SQL Language 2 May 30th, 2006 04:40 AM Count aggregate function Robert_Hill BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 August 24th, 2004 01:12 PM