Results 1 to 6 of 6
  1. #1
    Sengenbe is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    3

    Subtract Rows in Query Results

    Hi,

    I have a query which gives me the following information (simplified here):

    PropID --- AccountName --- 1Q2010 --- 2Q2010 ---> 4Q2020


    1000 --- RevenueAcct A --- #### --- #### --- ####
    1000 --- RevenueAcct B --- #### --- #### --- ####
    ...
    1000 --- ExpenseAcct A --- #### --- #### --- ####
    1000 --- ExpenseAcct B --- #### --- #### --- ####
    ...
    4929 --- RevenueAcct A --- #### --- #### --- ####
    etc.

    I want to either create a new query or append this query which will subtract each of the expenses and add each the revenues to get operating income. I have been playing trial and error here but only succeeded in adding another column containing errors, instead of my ideal result which would look like:

    PropID --- AccountName --- 1Q2010 --- 2Q2010 ---> 4Q2020
    1000 --- OperatingIncome --- #### --- #### --- ####
    4929 --- OperatingIncome --- #### --- #### --- ####
    1239 --- OperatingIncome --- #### --- #### --- ####
    etc.

    I need to keep the results to quarterly data separated by PropID. Is there an easy way to do this, or is it difficult in Access to do math between rows without using a function on the entire column like SUM()?

    Thanks!
    Last edited by Sengenbe; 02-08-2010 at 02:06 PM. Reason: Table readability

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    Use multiple queries to stack the data (in a temporary table) with appropriate signs in appropriate columns.

  3. #3
    Sengenbe is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    3
    llkhoutx,

    Thanks for your reply. Just so I am clear, do you mean that I should have a query for each revenue and expense line which applies the sign to each, then sum the lines in another query?

  4. #4
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    Misread your post.

    Use a Select Query (click the toolbar group by icon, the Sigma), then in the QBE frame Group By row, select sum for each of the Qtrs.

    The query, in design view, is in the attached jpg.

  5. #5
    NassauBob's Avatar
    NassauBob is offline Not THAT Green
    Windows XP Access 2003
    Join Date
    Feb 2010
    Location
    Augusta, GA
    Posts
    61
    The way that llkhoutx has instructed will work perfectly, as long as the Expenses are recorded in the table as negative values. That way, when they are added to the revenue values, they will actually be subtracted.

  6. #6
    Sengenbe is offline Novice
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    3
    PMs sent to both of you with the query details. I am limited in what I can show publicly and my summary may not convey what I need to.

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

Similar Threads

  1. Missing Counts that = 0 in query results
    By dandhjohn in forum Queries
    Replies: 1
    Last Post: 01-29-2010, 11:28 AM
  2. Weird Query results
    By UCBFireCenter in forum Queries
    Replies: 0
    Last Post: 10-06-2009, 03:38 PM
  3. display query results in a form
    By P5C768 in forum Queries
    Replies: 3
    Last Post: 08-14-2009, 03:02 PM
  4. Adding rows on cross-tab query report
    By KahluaFawn in forum Reports
    Replies: 2
    Last Post: 02-18-2009, 10:09 AM
  5. Entering query results in a form
    By marcello.dolcini in forum Forms
    Replies: 0
    Last Post: 04-15-2007, 06:01 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