Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Queries

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 02-08-2010, 10:19 AM
Sengenbe Sengenbe is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Feb 2010
Posts: 3
Sengenbe is on a distinguished road
Default 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 11:06 AM. Reason: Table readability
Reply With Quote
  #2  
Old 02-08-2010, 01:38 PM
llkhoutx llkhoutx is offline Windows Vista Access 2007 (version 12.0)
Expert
 
Join Date: Jan 2010
Location: Houston, Texas USA
Posts: 340
llkhoutx is on a distinguished road
Default

Use multiple queries to stack the data (in a temporary table) with appropriate signs in appropriate columns.
Reply With Quote
  #3  
Old 02-08-2010, 01:44 PM
Sengenbe Sengenbe is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Feb 2010
Posts: 3
Sengenbe is on a distinguished road
Default

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?
Reply With Quote
  #4  
Old 02-08-2010, 01:58 PM
llkhoutx llkhoutx is offline Windows Vista Access 2007 (version 12.0)
Expert
 
Join Date: Jan 2010
Location: Houston, Texas USA
Posts: 340
llkhoutx is on a distinguished road
Default

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.
Attached Images
File Type: jpg Sum Columns.jpg (73.9 KB, 6 views)
Reply With Quote
  #5  
Old 02-08-2010, 02:46 PM
NassauBob's Avatar
NassauBob NassauBob is offline Windows XP Access 2003 (version 11.0)
Not THAT Green
 
Join Date: Feb 2010
Location: Coastal North Carolina
Posts: 60
NassauBob is on a distinguished road
Default

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.
Reply With Quote
  #6  
Old 02-08-2010, 03:05 PM
Sengenbe Sengenbe is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Feb 2010
Posts: 3
Sengenbe is on a distinguished road
Default

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.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Missing Counts that = 0 in query results dandhjohn Queries 1 01-29-2010 08:28 AM
Weird Query results UCBFireCenter Queries 0 10-06-2009 01:38 PM
display query results in a form P5C768 Queries 3 08-14-2009 01:02 PM
Adding rows on cross-tab query report KahluaFawn Reports 2 02-18-2009 07:09 AM
Entering query results in a form marcello.dolcini Forms 0 04-15-2007 04:01 PM


All times are GMT -8. The time now is 02:42 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.