A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Math calculation



 
 
Thread Tools Display Modes
  #1  
Old July 16th, 2008, 03:46 PM posted to microsoft.public.access.queries
AC
external usenet poster
 
Posts: 95
Default Math calculation

Hi,

I have the Excel work sheet to calculate the data (about 25 columns and 300
rows) that are the data for making a chart in the Excel now. Because the
current Excel is not user friendly environment, I try to put every thing in
the Access. I used queries to calculate each cell’s value and some of cells
referring other cell’s value which are not on the same row (before or after
the current row). How can I write the queries to get referring row’s value?

The example like:
1. The equation is on the cell E8: E8 = X7 * C8
2. This is on the cell H8: H8 = H7+D8-Q7
3. And this is on the cell K8=(CalculatedResults!F14-H8)*($K$4/($I$4+$K$4))

Could you advise me how to handle this problem? Is this the right way to do
it? Thanks!

  #2  
Old July 16th, 2008, 05:05 PM posted to microsoft.public.access.queries
Michel Walsh[_2_]
external usenet poster
 
Posts: 56
Default Math calculation

You need to refer to the table with a different 'alias' for each row.

As a very simple example, if the table has a field 'SerialNumber' with
consecutive values without holes in the sequence, then:


SELECT actual.someField,
previous.someField AS someFieldPreviousRow,
nextOne.someField AS someFieldNextRow


FROM (myTable As actual
LEFT JOIN myTable AS previous
ON actual.serialNumber + 1 = previous.serialNumber)
LEFT JOIN myTable AS nextOne
ON actual.serialNumber - 1 = nextOne.serialNumber





can be a solution. Note that if the 'actual' row is the first one, then
previous (our alias for previous row) will only supply NULLs values, for any
of its fields, since such a row does not exist (under that context). That is
made possible by the left outer join.



Vanderghast, Access MVP



"Ac" wrote in message
...
Hi,

I have the Excel work sheet to calculate the data (about 25 columns and
300
rows) that are the data for making a chart in the Excel now. Because the
current Excel is not user friendly environment, I try to put every thing
in
the Access. I used queries to calculate each cell’s value and some of
cells
referring other cell’s value which are not on the same row (before or
after
the current row). How can I write the queries to get referring row’s
value?

The example like:
1. The equation is on the cell E8: E8 = X7 * C8
2. This is on the cell H8: H8 = H7+D8-Q7
3. And this is on the cell
K8=(CalculatedResults!F14-H8)*($K$4/($I$4+$K$4))

Could you advise me how to handle this problem? Is this the right way to
do
it? Thanks!


  #3  
Old July 16th, 2008, 06:09 PM posted to microsoft.public.access.queries
Michel Walsh[_2_]
external usenet poster
 
Posts: 56
Default Math calculation

.... have to exchange the +1 and -1 :



ON actual.serialNumber -1 = previous.serialNumber)
LEFT JOIN myTable AS nextOne
ON actual.serialNumber +1= nextOne.serialNumber



Vanderghast, Access MVP


"Michel Walsh" wrote in message
...
You need to refer to the table with a different 'alias' for each row.

As a very simple example, if the table has a field 'SerialNumber' with
consecutive values without holes in the sequence, then:


SELECT actual.someField,
previous.someField AS someFieldPreviousRow,
nextOne.someField AS someFieldNextRow


FROM (myTable As actual
LEFT JOIN myTable AS previous
ON actual.serialNumber + 1 = previous.serialNumber)
LEFT JOIN myTable AS nextOne
ON actual.serialNumber - 1 = nextOne.serialNumber





can be a solution. Note that if the 'actual' row is the first one, then
previous (our alias for previous row) will only supply NULLs values, for
any of its fields, since such a row does not exist (under that context).
That is made possible by the left outer join.



Vanderghast, Access MVP



"Ac" wrote in message
...
Hi,

I have the Excel work sheet to calculate the data (about 25 columns and
300
rows) that are the data for making a chart in the Excel now. Because the
current Excel is not user friendly environment, I try to put every thing
in
the Access. I used queries to calculate each cell’s value and some of
cells
referring other cell’s value which are not on the same row (before or
after
the current row). How can I write the queries to get referring row’s
value?

The example like:
1. The equation is on the cell E8: E8 = X7 * C8
2. This is on the cell H8: H8 = H7+D8-Q7
3. And this is on the cell
K8=(CalculatedResults!F14-H8)*($K$4/($I$4+$K$4))

Could you advise me how to handle this problem? Is this the right way to
do
it? Thanks!



  #4  
Old July 16th, 2008, 07:35 PM posted to microsoft.public.access.queries
AC
external usenet poster
 
Posts: 95
Default Math calculation

Thanks! I will try.



"Michel Walsh" wrote:

... have to exchange the +1 and -1 :



ON actual.serialNumber -1 = previous.serialNumber)
LEFT JOIN myTable AS nextOne
ON actual.serialNumber +1= nextOne.serialNumber



Vanderghast, Access MVP


"Michel Walsh" wrote in message
...
You need to refer to the table with a different 'alias' for each row.

As a very simple example, if the table has a field 'SerialNumber' with
consecutive values without holes in the sequence, then:


SELECT actual.someField,
previous.someField AS someFieldPreviousRow,
nextOne.someField AS someFieldNextRow


FROM (myTable As actual
LEFT JOIN myTable AS previous
ON actual.serialNumber + 1 = previous.serialNumber)
LEFT JOIN myTable AS nextOne
ON actual.serialNumber - 1 = nextOne.serialNumber





can be a solution. Note that if the 'actual' row is the first one, then
previous (our alias for previous row) will only supply NULLs values, for
any of its fields, since such a row does not exist (under that context).
That is made possible by the left outer join.



Vanderghast, Access MVP



"Ac" wrote in message
...
Hi,

I have the Excel work sheet to calculate the data (about 25 columns and
300
rows) that are the data for making a chart in the Excel now. Because the
current Excel is not user friendly environment, I try to put every thing
in
the Access. I used queries to calculate each cell’s value and some of
cells
referring other cell’s value which are not on the same row (before or
after
the current row). How can I write the queries to get referring row’s
value?

The example like:
1. The equation is on the cell E8: E8 = X7 * C8
2. This is on the cell H8: H8 = H7+D8-Q7
3. And this is on the cell
K8=(CalculatedResults!F14-H8)*($K$4/($I$4+$K$4))

Could you advise me how to handle this problem? Is this the right way to
do
it? Thanks!



 




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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:38 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.