Results 1 to 3 of 3
  1. #1
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215

    Calculate YTD and Rolling-12 Month Totals

    I have four fields of information



    Year | Month | Type | SubType | Value




    I want to group first based on Type and then on the SubType and do a YTD and Rolling-12 calculation based on the Year and Month provided. This will undoubtedly be 2 separate queries.

    Also, IF POSSIBLE:


    If there ARE NOT 12 months to "roll" on for a particular month, to show a "-" or something to signify that there are not 12-months to roll on.


    I'm really just not skilled enough to write this query. If someone can help me write it, I would be unbelievably appreciative.

  2. #2
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215
    I figured out how to do the YTD calculation in it's own query.

    Month_Year is just a field of standard dates of the form 1/2/2015 or whatever.

    Code:
    SELECT b.OE, b.ValueID, b.MetricID, b.Month_Year, (select sum(a.Value) 
            from ValueT as a 
            where a.Months <= b.Months AND a.Years = b.Years and
                  a.MetricID = b.MetricID and a.OE = b.OE
           ) AS ValueYTD INTO new_table
    FROM ValueT AS b
    GROUP BY b.OE, b.ValueID, b.MetricID, b.Month_Year, b.Months, b.Years
    ORDER BY b.OE, b.MetricID, b.Month_Year;

  3. #3
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,845

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Calculate YTD and Rolling-12 Months Totals?
    By McArthurGDM in forum Access
    Replies: 7
    Last Post: 04-08-2015, 11:37 AM
  2. Rolling 3 month and 12 month Calculation
    By REGeekker in forum Programming
    Replies: 10
    Last Post: 03-30-2015, 07:29 PM
  3. Replies: 43
    Last Post: 08-06-2014, 08:21 PM
  4. Replies: 2
    Last Post: 04-29-2014, 03:04 AM
  5. Rolling 3 Month sums
    By michaeljohnh in forum Reports
    Replies: 1
    Last Post: 11-08-2010, 05:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums