Results 1 to 2 of 2
  1. #1
    tjstromquist is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    2

    SUM based on date range in query builder

    I would like to create some custom columns of data within my query.

    I would like to create the following column: Last4WeeksQty. It would be something like
    Last4WksQty: IIf(([dbo_Depot_Buckets.Date_Start]) Between (([dbo_Depot_Buckets.Date_Start])-21) And ([dbo_Depot_Buckets.Date_Start]),([Qty_Sold]),0))

    The above formula retuns a number but it is not summing correctly, it is just returning the qty of that week....

    Current query shows:


    Year DateStart Week SKU Qty Dlrs
    2012 03-26-2012 9 315554 10 45
    2012 03-19-2012 8 55456 15 66
    2012 03-12-2012 7 654496 154 545
    2012 03-05-2012 6 465465 654 654
    2012 02-27-2012 5 56684 544 441

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You would need to use either a subquery or a DSum() function to accomplish what you are after

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

Similar Threads

  1. Query Date Range Based on Calculated Fields
    By wilsoa in forum Queries
    Replies: 6
    Last Post: 03-08-2012, 02:41 PM
  2. joins based on date range
    By broecher in forum Database Design
    Replies: 4
    Last Post: 11-04-2011, 06:32 PM
  3. Run query by date range
    By ARickert in forum Access
    Replies: 2
    Last Post: 06-23-2011, 10:54 AM
  4. Replies: 13
    Last Post: 09-27-2010, 03:10 PM
  5. Replies: 3
    Last Post: 09-29-2009, 07:08 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