Hans V said:
In an Access database query I have a table/ query with values per week (52
weeks), shown in 52 columns.
I can't find the right way to find to the summary; average and Max -value
within a row.
As I do have next to none knowledge of visual basic, and I can't find the
solution within the design grid, I'm looking for some help on this subject.
The reason you can not find a convenient way to do that is
because your table is designed to look like a spreadsheet.
A relational database like Access needs to be designed
following the rules of database Normalization that has that
kind of data in rows instead of columns. See
http://support.microsoft.com/kb/289533/en-us
At this point, I can only think of four choices you have to
dealing with your problem (in order of decreasing
effectiveness):
1) Normalize your data tables
This will allow the standard database functions to
calculate the desired values in a very straightforward
way. It will also avoid all kinds of other problems you
have not run into yet.
2) Simulate a normalized table by creating a UNION query.
This kind of query will put the weekly values in a
single column:
SELECT pk, 1 As Week, wk1 As WkVal FROM table
UNION ALL
SELECT pk, 2, wk2 FROM table
UNION ALL
. . .
. . .
Then you use that query as the source for a standard
query to calculate the aggregate values:
SELECT pk, Sum(WkVal) As YrTotal,
Avg(WkVal) As YrAvg,
Max(WkVal) As YrMax
FROM qryNorm
GROUP BY pk
Even if you don't exceed the limits on Union queries,
this approach may get you past the current problem,
it may be too slow to be useful and it may not help with
future problems.
3) Move your data to Excel
While this will make other data operations more
difficult, at least you can perform those column
operations using spreadsheet functions.
4) Use some very messy expressions in your query.
For example, the sum of the columns would be:
Nz(wk1,0) + Nz(wk2,0) + . . .
The Max will be especially complex and will probably
exceed several limits for expressions.