Results 1 to 5 of 5
  1. #1
    h0raz0n is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2017
    Posts
    2

    Simple YTD query... Access newbie here

    Hi everyone

    I have a set of data which is the total budget for the year and the monthly breakdown (ie. Budget full year, Budget Jan month-to-date, budget feb month-to-date,....., budget dec month-to-date). They are pulled from the server so I am unable to change how the data is presented.

    The monthly values are calculated over a curve so I cannot just take the total and divide by 12.



    I am trying to create a budget year-to-date column where it will sum up the monthly columns depending at the last completed month (ie. Month(Now())-1).

    May I know how can I do that?


    In excel I would simply use a Sum combined with Offset function.

    Thanks.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    My query uses the form to get the date range,...
    select * from table where date between forms!myForm!txtStartDate and forms!myForm!txtEndDate

    Speed settings (ytd, montly, etc) set the date range quick, but the user can set it too.

    Click image for larger version. 

Name:	rpts ytd.jpg 
Views:	14 
Size:	45.5 KB 
ID:	30035

  3. #3
    h0raz0n is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2017
    Posts
    2
    I do not have a date range, the data is presented with just the headers [BUD-01],[BUD-02],....[BUD-12] for the months and the rows listing the sales numbers.
    It is not actual sales where I can make use of invoice dates.

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    What does the data look like? Is it just the one record with the values you described? If so, add an if statement to each of the fields:

    FebAmt: IIf(Month(Date()<2,0,[BUD-02])
    MarAmt: IIf(Month(Date()<3,0,[BUD-03])
    etc

    Then in a second query you can add up all the fields: TotalAmt: JanAmt+FebAmt+MarAmt....

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Review http://allenbrowne.com/subquery-01.html#YTD

    Your data structure appears not to be normalized.

    A report may be best vehicle for you to do running sum.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-15-2017, 01:19 PM
  2. Simple Validation question from newbie
    By benLL in forum Access
    Replies: 1
    Last Post: 11-26-2015, 09:03 AM
  3. Simple problem. Newbie Question
    By thalor in forum Programming
    Replies: 9
    Last Post: 07-03-2014, 12:43 PM
  4. Simple problem from a newbie user
    By jimmy2x2x in forum Access
    Replies: 3
    Last Post: 10-23-2011, 04:36 PM
  5. Newbie, seems simple to lookup value?!
    By ayce123 in forum Queries
    Replies: 3
    Last Post: 03-13-2011, 12:22 PM

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