Results 1 to 5 of 5
  1. #1
    davetedwards is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    2

    Subtract Groups


    Alright I've got a report based of a query giving me information grouped by club and then by year and then month. I need to take the sum of units for a month and subtract the previous months total. I don't know how to get last months sum to subtract it. I've seen some things online about using if's but I don't see how that would work. I don't know if I need to create a new quarry where it renumbers all the months so that last month comes up as the same month?

    Dave

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    In a new and seperate query you could create an alias field (along with other alias fields for report grouping, etc.) using the month function

    CompareDate: Month([DateFieldName])+1

    You would use this field to create a join to your original query.

    If you can, do the calculations in the report.

    Test it and see. If your new query does not support the report correctly you may have to go to a temp table. I think you should be able to get the join you need for your report though using this single alias in a new query.

  3. #3
    A S MANN is offline Advanced System Analyst
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    India
    Posts
    161
    You can Create a New Table Containg All Privious Month Units. Append Monthly data After End of Every Month.
    Create New Query and in it Join This New table and Current Month Unit Ttotals
    Take this new query as record Source of ur report

  4. #4
    davetedwards is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    2
    Quote Originally Posted by ItsMe View Post
    In a new and seperate query you could create an alias field (along with other alias fields for report grouping, etc.) using the month function

    CompareDate: Month([DateFieldName])+1

    You would use this field to create a join to your original query.

    If you can, do the calculations in the report.

    Test it and see. If your new query does not support the report correctly you may have to go to a temp table. I think you should be able to get the join you need for your report though using this single alias in a new query.
    I wanted to do this. I set up a new query and had another column for last month which was equal to month +1, the month is just a number 1-12. The problem comes in the report, when I go to run it I'm prompted with whatever the table is called. The report is already grouping information by month. I there should be some easy way to say take the sum of units and subtract the sum of units from the month before.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Hmmmmm, you would need to build a second and separate query in the query builder. In this second query have a couple of collumns. One would have the date and the other would have your expression to add a number to the month of the date.

    In you original query (that the report depends upon), add a column to it. This column would use the month function to get the actual and real number of the month for that given record.

    With that, you can bring the second query you created into your first query. Join on the month number columns you created. Then create an alias for the date field of the second query. Creating an alias will help you to distinguish this field as an historical date value in your original query and within your report.

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

Similar Threads

  1. if checkbox= true subtract 8.75 from A to=B
    By VanillaAwesome in forum Queries
    Replies: 6
    Last Post: 07-28-2012, 12:48 PM
  2. Replies: 3
    Last Post: 07-11-2012, 05:13 PM
  3. Subtract from Previous Row
    By lambo102 in forum Queries
    Replies: 1
    Last Post: 08-06-2011, 09:39 AM
  4. How to do subtract in Query
    By NoOoN in forum Queries
    Replies: 6
    Last Post: 04-07-2011, 01:15 PM
  5. Subtract from inventory
    By NISMOJim in forum Access
    Replies: 5
    Last Post: 01-30-2011, 01:09 PM

Tags for this Thread

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