i have a table in which i store a value on daily basis. so, i have 30 values for a month. Now i want to get %variation in values on daily basis. Please tell me the function to be used and how in m.access
5 1537
i have a table in which i store a value on daily basis. so, i have 30 values for a month. Now i want to get %variation in values on daily basis. Please tell me the function to be used and how in m.access
Shalini,
You're going to have to provide more information as to what kind of table structure, queries, forms, and what controls on the forms that you have defined.
Since we don't know anything about what you're trying to do, any examples of what you have, and what you want the end result to be, would be greatly appreciated.
Thanks,
Joe P.
i have a table comp_mst having fields as
comp_name
sym PK
price_vol having fields as
id PK
sym
date
vol
price
`
now i will be storing volume and price values of all companies daily basis.In a query i want to have daily % variation of the volume and price.
till now i have created one query to find out previous date using dateadd()
then 2nd query to find out corresponding value
and i have 3rd one which is simply picking value from price_vol and query to get diffrence.but in this query i am getting cartision product.can you pls guide me
The following code will calculate the Percentage Differential (+/-) between Volumes of successive Records based on the price_vol Table structure. Calculations for Price Differential would be very similar. The results can very easily be written to a Table instead of being dumped to the Debug Screen: - Dim MyDB As DAO.Database
-
Dim rst_1 As DAO.Recordset
-
Dim rst_Clone As DAO.Recordset
-
Dim strPVar As String
-
Dim strBig As String
-
-
Set MyDB = CurrentDb()
-
Set rst_1 = MyDB.OpenRecordset("price_vol", dbOpenDynaset)
-
Set rst_Clone = rst_1.Clone 'Exact Duplicate of rst_1
-
-
If rst_1.RecordCount = 0 Then Exit Sub
-
-
rst_1.MoveFirst
-
rst_Clone.MoveFirst: rst_Clone.MoveNext 'Move to 2nd Record
-
-
Debug.Print "Volume 1 Volume 2 %Variance"
-
Debug.Print "----------------------------------"
-
-
With rst_1
-
Do While Not rst_Clone.EOF
-
'Calculate the Percent Variation
-
If rst_Clone![vol] >= ![vol] Then '2nd > 1st
-
strPVar = "+" & Format(((rst_Clone![vol] - ![vol]) / ![vol]), "Percent")
-
Else
-
strPVar = "-" & Format(((![vol] - rst_Clone![vol]) / ![vol]), "Percent")
-
End If
-
strBig = " " & Format$(![vol], "0000") & " " & _
-
Format$(rst_Clone![vol], "0000") & _
-
" " & strPVar
-
Debug.Print strBig
-
.MoveNext
-
rst_Clone.MoveNext
-
Loop
-
End With
-
-
rst_1.Close
-
Set rst_1 = Nothing
-
rst_Clone.Close
-
Set rst_Clone = Nothing
price_vol Data - ID sym date vol price
-
1 45 6/2/2008 100 $125.00
-
2 46 7/14/2008 200 $137.00
-
3 47 1/29/2008 125 $117.00
-
4 48 12/12/2008 400 $150.00
-
5 49 11/16/2008 500 $234.00
-
6 50 3/3/2008 600 $97.00
-
7 51 9/21/2008 400 $112.00
-
8 52 5/31/2008 800 $298.00
-
9 53 9/2/2008 327 $200.00
-
10 54 4/12/2008 1000 $213.00
-
11 888 11/23/2008 1000 $323.00
OUTPUT -
Volume 1 Volume 2 %Variance
-
----------------------------------
-
0100 0200 +100.00%
-
0200 0125 -37.50%
-
0125 0400 +220.00%
-
0400 0500 +25.00%
-
0500 0600 +20.00%
-
0600 0400 -33.33%
-
0400 0800 +100.00%
-
0800 0327 -59.13%
-
0327 1000 +205.81%
-
1000 1000 +0.00%
-
thanks alot for the wonderful solution.Actually i have got the correct ans using query also.I have one more question as i am not very much good in access.
I want to put a button on my form to perform events.but when i try to put it , it doesn't show the wizard for events , nor any of the control is showing events in there property .what could be the problem ?
thanks alot for the wonderful solution.Actually i have got the correct ans using query also.I have one more question as i am not very much good in access.
I want to put a button on my form to perform events.but when i try to put it , it doesn't show the wizard for events , nor any of the control is showing events in there property .what could be the problem ?
Make sure you click on the Control Wizards Button on the Toolbox in order to activate it prior to drawing any Controls on your Form. It is the 2nd Button Horizontally from the Upper Left Corner, and its Icons consists of an Ellipses (...) as well as a Magic Wand (\).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: tamilan71 |
last post by:
Hello All
I have table with following fields:
GroupId VisitDate
1 10/19/1993
1 11/24/1998
2 10/18/1993
2 10/29/1998
3 ...
|
by: Ashish Sheth |
last post by:
Hi All,
In C#, How can I get the difference between two dates in number of months?
I tried to use the Substract method of the DateTime class and it is
giving me the difference in TimeSpan,From...
|
by: Simon Dean |
last post by:
Probably being a little thick here, but when you subtract one date away
from another, how do you convert the resultant value into a number of
days... I guess I could easily / 60 / 60 / 24... but...
|
by: jamesyreid |
last post by:
Hi,
I'm really sorry to post this as I know it must have been asked
countless times before, but I can't find an answer anywhere.
Does anyone have a snippet of JavaScript code I could borrow...
|
by: Yotam |
last post by:
Hi,
I need some help with JS. I will be grateful, if you can help me out.
I have two date fields (check in, check out) and "number of days"
field.
I want the script to calculate automatically...
|
by: Blackmore |
last post by:
I am trying to use javascript to calculate the difference between two form inputted dates and return the result to another form object. When I load up the page with the function on my web browser...
|
by: Claudia Fong |
last post by:
Hi,
In VB we have DateDiff to calculate the days difference between 2 dates,
I was wondering if we
have something like that in C#?
I want to calculate for example the days difference...
|
by: Julius |
last post by:
Hej dudes,
I need to calc the difference between two timestamps / dates ...
For example what i need to calculate:
Date 1: 2007.11.06 - 20:13:04
Date 2: 2007.11.07 - 21:13:04
Difference:...
|
by: Mike |
last post by:
I use c#, V2005
How I can get difference between two dates and get value in month(s)
I had found some solutions but it is not exactly what I need.
private static int...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |