S
Susan
Hello,
I'm hoping that Tom Ellison still is about on this page. I've just been
reading his posts for "help with calculations in a query" 11/04/2005 - Which
I have a similar problem with and have previous found help with on this site.
My problem is reading metered gas on consecutive times (not dates but
intervals).
This solution that I previous had involved this:
mLDif10:
Switch([time_slice]=0,[10],[time_slice]=1,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=0")),[time_slice]=2,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=1")),[time_slice]=3,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=2")),[time_slice]=4,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=3")),[time_slice]=5,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=4")),[time_slice]=6,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=5")),[time_slice]=7,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=6")),[time_slice]=8,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=7")),[time_slice]=9,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=8")),[time_slice]=10,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=9")),[time_slice]=11,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=10")),[time_slice]=12,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=11")),[time_slice]>13,-1)
Basically what I have is a union query taking data from txt files (one for
each "flask" i.e. [10] in the above example) into one query. I then use the
crosstab to seperate the individual "flasks"....and then I run the above, one
forumla for each flask.
The problems are it's very slow (about 30-45 min), and I can only do the
first 13 "time slices" because of feild size limitations.
Having read Tom's response to "help with calculations in a query" I'm hoping
there is a better solution to my problem. In my case "flask" is like the name
of each water meter and "mL_gas" is like the meter reading.
I can't quite understand the solution posted by Tom. By the sounds of it my
data is correctly normalised (I have many (36) rows of data for one
"time_slice" or date-equivalent).
I don’t understand what he means by “Filter it with so one table has the
reading date equal to Forms![Meter Usage]!Date and the other to the same
date minus 1â€.
This is what I wrote for my data:
SELECT Qry_TimeVrsO2.Time_slice AS Time_slice, Qry_TimeVrsO2.Flask,
Qry_TimeVrsO2.[mL gas], [Qry_TimeVrsO2_1].[time_slice]-1 AS Time_sliceb4
FROM Qry_TimeVrsO2 AS Qry_TimeVrsO2_1 INNER JOIN Qry_TimeVrsO2 ON
Qry_TimeVrsO2_1.Flask = Qry_TimeVrsO2.Flask
ORDER BY Qry_TimeVrsO2.Time_slice, Qry_TimeVrsO2.Flask;
Which doesn’t really work as I get multiple results for each Time_Slice:
Time_slice Flask mL gas Time_sliceb4
0 1 183.9 2
0 1 183.9 1
0 1 183.9 -1
0 1 183.9 0
0 1 183.9 3
Tom goes on to use another query to make the subtraction with:
SELECT *
FROM [Meter Usage] MU0, [Meter Usage] MU1
WHERE MU0.Date = #11/26/05#
AND MU1.Date = #11/25/05#
AND MU1.MeterID = MU0.MeterID
I have yet tried this as I want to get the first query working right first.
But my main question is what does MU0 and MU1 relate to? Will this only give
the result for the 11/25/05? … I need it to work for all “times†(I have 29
time slices)
Any help greatly appreciated
Thanks
Susan
I'm hoping that Tom Ellison still is about on this page. I've just been
reading his posts for "help with calculations in a query" 11/04/2005 - Which
I have a similar problem with and have previous found help with on this site.
My problem is reading metered gas on consecutive times (not dates but
intervals).
This solution that I previous had involved this:
mLDif10:
Switch([time_slice]=0,[10],[time_slice]=1,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=0")),[time_slice]=2,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=1")),[time_slice]=3,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=2")),[time_slice]=4,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=3")),[time_slice]=5,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=4")),[time_slice]=6,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=5")),[time_slice]=7,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=6")),[time_slice]=8,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=7")),[time_slice]=9,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=8")),[time_slice]=10,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=9")),[time_slice]=11,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=10")),[time_slice]=12,([10]-DLookUp("[10]","qry_crosstab_o2_co2trap","[time_slice]=11")),[time_slice]>13,-1)
Basically what I have is a union query taking data from txt files (one for
each "flask" i.e. [10] in the above example) into one query. I then use the
crosstab to seperate the individual "flasks"....and then I run the above, one
forumla for each flask.
The problems are it's very slow (about 30-45 min), and I can only do the
first 13 "time slices" because of feild size limitations.
Having read Tom's response to "help with calculations in a query" I'm hoping
there is a better solution to my problem. In my case "flask" is like the name
of each water meter and "mL_gas" is like the meter reading.
I can't quite understand the solution posted by Tom. By the sounds of it my
data is correctly normalised (I have many (36) rows of data for one
"time_slice" or date-equivalent).
I don’t understand what he means by “Filter it with so one table has the
reading date equal to Forms![Meter Usage]!Date and the other to the same
date minus 1â€.
This is what I wrote for my data:
SELECT Qry_TimeVrsO2.Time_slice AS Time_slice, Qry_TimeVrsO2.Flask,
Qry_TimeVrsO2.[mL gas], [Qry_TimeVrsO2_1].[time_slice]-1 AS Time_sliceb4
FROM Qry_TimeVrsO2 AS Qry_TimeVrsO2_1 INNER JOIN Qry_TimeVrsO2 ON
Qry_TimeVrsO2_1.Flask = Qry_TimeVrsO2.Flask
ORDER BY Qry_TimeVrsO2.Time_slice, Qry_TimeVrsO2.Flask;
Which doesn’t really work as I get multiple results for each Time_Slice:
Time_slice Flask mL gas Time_sliceb4
0 1 183.9 2
0 1 183.9 1
0 1 183.9 -1
0 1 183.9 0
0 1 183.9 3
Tom goes on to use another query to make the subtraction with:
SELECT *
FROM [Meter Usage] MU0, [Meter Usage] MU1
WHERE MU0.Date = #11/26/05#
AND MU1.Date = #11/25/05#
AND MU1.MeterID = MU0.MeterID
I have yet tried this as I want to get the first query working right first.
But my main question is what does MU0 and MU1 relate to? Will this only give
the result for the 11/25/05? … I need it to work for all “times†(I have 29
time slices)
Any help greatly appreciated
Thanks
Susan