473,789 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repost- Calculating the difference in two values

SORRY I know we shouldn't do this but I'm desperate for an answer to this
and the previous post didn't seem to get a response.

I have a table with two fields, txtvalue (a number field) and txtmonth ( a
date/time field). I want to create a report that shows the difference in
value between the value in txtvalue in one value of txtmonth and the value
of txtvalue in another value of txtmonth and the percentage increase . For
example if I have the value 1000 in 30/03/03 and the value 1100 in 30/03/04
How do I calculate the difference as 100 and the increase as 10%. I want to
do this in a report.

I've tried using an append query to create a dummy table but couldn't get
that to work at all. Anyone any ideas? This seems such a simple calculation
that would be easy in Excel but I want to produce an Access report.

TIA
Tony Williams
Nov 13 '05 #1
6 3382
Tony Williams wrote:
SORRY I know we shouldn't do this but I'm desperate for an answer to this
and the previous post didn't seem to get a response.

I have a table with two fields, txtvalue (a number field) and txtmonth ( a
date/time field). I want to create a report that shows the difference in
value between the value in txtvalue in one value of txtmonth and the value
of txtvalue in another value of txtmonth and the percentage increase . For
example if I have the value 1000 in 30/03/03 and the value 1100 in 30/03/04
How do I calculate the difference as 100 and the increase as 10%. I want to
do this in a report.

I've tried using an append query to create a dummy table but couldn't get
that to work at all. Anyone any ideas? This seems such a simple calculation
that would be easy in Excel but I want to produce an Access report.


It is not very straightforward in a database system, because tables are
unordered in principle.

All following SQL is air code.

You can have a query that finds the next date using two steps:

(1) have the table twice in the first query, but for the second date
enter criteria >firsttable.txt month
In SQL it could look like this:

SELECT t1.txtMonth AS firstDate, t2.txtMonth AS laterDate
FROM yourtable AS t1, yourtable AS t2
WHERE t2.txtMonth>t1. txtMonth

Save this as qTriangle (if you visualize the result set as t1 in rows,
t2 in columns, you may see why I name it thus)

(2) create a query on this query, grouping by first date, Min-ing second
date:

SELECT firstDate AS theDate, Min(laterDate) AS nextDate
FROM qTriangle
GROUP BY firstDate

Save this as qDatePair

This query you can use as 'pole' to connect the original table to, to
find the corresponding txtValues:

SELECT t1.txtValue AS theValue, t2.txtValue AS valueNextMonth, theDate
FROM (qDatePair INNER JOIN yourtable AS t1 on
t1.txtMonth=qDa tePair.theDate) INNER JOIN yourtable AS t2 on
qDatePair.nextD ate=t2.txtMonth

This query can be used in the report, making the calculation you ask for
a trivial action. I hope.
--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #2
Tony Williams wrote:
SORRY I know we shouldn't do this but I'm desperate for an answer to this
and the previous post didn't seem to get a response.


At least you clearly state 'repost'!

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #3
Thanks Bas I'm a newbie so that went over my head a bit, I'm going to need
time to study that. Is there any site that shows examples of this?
Tony
"Bas Cost Budde" <b.*********@he uvelqop.nl> wrote in message
news:cp******** **@news2.solcon .nl...
Tony Williams wrote:
SORRY I know we shouldn't do this but I'm desperate for an answer to this and the previous post didn't seem to get a response.

I have a table with two fields, txtvalue (a number field) and txtmonth ( a date/time field). I want to create a report that shows the difference in
value between the value in txtvalue in one value of txtmonth and the value of txtvalue in another value of txtmonth and the percentage increase . For example if I have the value 1000 in 30/03/03 and the value 1100 in 30/03/04 How do I calculate the difference as 100 and the increase as 10%. I want to do this in a report.

I've tried using an append query to create a dummy table but couldn't get that to work at all. Anyone any ideas? This seems such a simple calculation that would be easy in Excel but I want to produce an Access report.


It is not very straightforward in a database system, because tables are
unordered in principle.

All following SQL is air code.

You can have a query that finds the next date using two steps:

(1) have the table twice in the first query, but for the second date
enter criteria >firsttable.txt month
In SQL it could look like this:

SELECT t1.txtMonth AS firstDate, t2.txtMonth AS laterDate
FROM yourtable AS t1, yourtable AS t2
WHERE t2.txtMonth>t1. txtMonth

Save this as qTriangle (if you visualize the result set as t1 in rows,
t2 in columns, you may see why I name it thus)

(2) create a query on this query, grouping by first date, Min-ing second
date:

SELECT firstDate AS theDate, Min(laterDate) AS nextDate
FROM qTriangle
GROUP BY firstDate

Save this as qDatePair

This query you can use as 'pole' to connect the original table to, to
find the corresponding txtValues:

SELECT t1.txtValue AS theValue, t2.txtValue AS valueNextMonth, theDate
FROM (qDatePair INNER JOIN yourtable AS t1 on
t1.txtMonth=qDa tePair.theDate) INNER JOIN yourtable AS t2 on
qDatePair.nextD ate=t2.txtMonth

This query can be used in the report, making the calculation you ask for
a trivial action. I hope.
--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea

Nov 13 '05 #4
Tony Williams wrote:
Thanks Bas I'm a newbie so that went over my head a bit, I'm going to need
time to study that. Is there any site that shows examples of this?


Not yet. I hoped you supplied the real names, in that case you can cut
the SQL and paste it in queries. It would work.

To create an example would take me some time that I don't have before
next week. If you can wait that long, please do; if not, you can mail me
for a consult.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #5
Thanks Bas, I'll have a go. Actually there are about 8 values that I need to
do this calculation on in the same report. Can I assume that I just repeat
the code for each value?
Thanks
Tony
"Bas Cost Budde" <b.*********@he uvelqop.nl> wrote in message
news:cp******** **@news2.solcon .nl...
Tony Williams wrote:
Thanks Bas I'm a newbie so that went over my head a bit, I'm going to need time to study that. Is there any site that shows examples of this?


Not yet. I hoped you supplied the real names, in that case you can cut
the SQL and paste it in queries. It would work.

To create an example would take me some time that I don't have before
next week. If you can wait that long, please do; if not, you can mail me
for a consult.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea

Nov 13 '05 #6
Tony Williams wrote:
Thanks Bas, I'll have a go. Actually there are about 8 values that I need to
do this calculation on in the same report. Can I assume that I just repeat
the code for each value?


If for all values you want to -er- progress on the same date, no, you
can have all values in the last query and do the report at once.

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
I prefer human mail above automated so in my address
replace the queue with a tea
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1761
by: Joe | last post by:
Please repost answer message did not make it last time Hello, Joe here, wanted to get the 411 on this article. I posted in the FrontPage forum but there is never an answer. So I have come here, where all my IIS problems have been solved (Thank YOU!!) I want to create a small utility web site with a logon page and a form connected to an Access database. The article below explains exactly how but when
4
2270
by: Mike Lundell | last post by:
lemee try this again, for today's date :)... .............. what's wrong with this, and .. can you not declare "char" variables? #include <iostream> int main() {
2
1812
by: Ohaya | last post by:
Hi, We've been having a problem with one particular page that has a button on it, and a "tall" image (top-to-bottom). The button calls some simple Javascript to print the frame in which the image is located, and what is happening in the field is that the image only gets partly printed. Only the first page gets printed, and the bottom of the image, which should get printed on a 2nd page, is not printed. Also, the bottom of the first...
1
1260
by: Fresh Air Rider | last post by:
Hi Everyone Scenario A Webage has two dropdown lists, one for Suppliers and one for Products. When a user selects a supplier, it then populates the Products dropdown list with the relevant products for the selected supplier.
0
1258
by: rawCoder | last post by:
Hi All, This is a repost of 'Disable DataGrid AutoScroll of 3/7/2005' Its related to "WinForm DataGrid" HOW can i force the grid NOT to Auto Scroll to the ( newly added item OR last selected item )? Currently as a new item is entered, the grid SCROLLS hence changing the
3
1871
by: Adam | last post by:
I've posted about this previously, but failed to receive a satisfactory response, so have included a code sample: I am trying to receive messages from an HTML viewer control in compact.net (c#), but cannot use message window as the control's parent window, as this is invisible and so the html is not viewable! I have a code sample showing the problem at www.tenwisevirgins.com/Example.zip
14
2840
by: Steve McLellan | last post by:
Hi, Sorry to repost, but this is becoming aggravating, and causing me a lot of wasted time. I've got a reasonably large mixed C++ project, and after a number of builds (but not a constant number) linking (and sometimes compiling) becomes immensely slow, and task manager shows that link.exe (or cl.exe) is barely using any processor time, but an awful lot of RAM (around 150-200MB). I'm going to keep an eye on page faults since I can't...
5
2448
by: Adrian Parker | last post by:
I've got the standard SqlCacheDependency working just fine , ie. I've defined (and encrypted) the connectionStrings section in the web.config, and I've also defined an an sqlCacheDependency in the caching section. So, in my code I add an item to the cache with an sqlCacheDependency, referencing the named sqlCacheDependency in the web.config and the database table it is to be based on (have enabled notificiations for that table). Fine. ...
2
1311
by: Gerry | last post by:
I have a combo box and I can populate it with my class of dat (the class allows me to store each userid,username called - see code below I want the user to select the dropdown and see the username - but also determine the UserID from what was selected (using DisplayName from the combo box?? I can populate the combo box without problems - BUT the user sees "System.object" in each item of the combobox not the username ***here is my clas...
2
1454
by: Raj | last post by:
Hi, I have the following problem. I am displaying and printing a PDF file that is generated by my Application server. The print dialogs comes up correctly for the small PDF for the larger PDFs ,the print dialog for the Acrobat reader does not comes up. I believe this is because print method is called before the complete loading of the PDF document. <html> <Head> <script>
0
10410
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.