For a crosstab, I'd create a utility table like this, and put one record in the table for each column I wanted to see in the crosstab. A column can be a single semester or a range of semesters.
Code:
tblCross1
CrossPK PK Autonumber
CrossTitle Text
FirstSem Number
LastSem Number
FirstSem LastSem CrossTitle
00 07 2008-09 Year & Prev
08 09 2009-10 Year
10 11 2010-11 Year
12 12 2011 Fall
13 13 2012 Spring
14 14 2012 Fall
15 15 2013 Spring
16 16 2013 Fall
00 99 Cumulative
You can see by the dataq above that, to get the Crosstab titles to arrange themselves correctly, I used an extra space before the word "Spring", otherwise the column for "2012 Fall" sorts to the left of "2012 Spring".
Here's the crosstab query to show the student's step-by-step weighed averages
Code:
Query3:
TRANSFORM Format((Sum(SemWeight)/Sum(SemUnits)),"0.00") AS SemAvg
SELECT Q1.Index
FROM Query1 AS Q1, tblCross AS C1
WHERE ( Q1.Semester BETWEEN C1.FirstSem AND C1.LastSem)
GROUP BY Q1.Index
PIVOT C1.CrossTitle;
With the same SQL code and different data in tblCross, you could create columns of running cums or whatever else you'd like.
If you wanted to have three lines per student, one each for the Units, Weight and Average, then you can create a second table like this:
Code:
tblCross2
CrossValue Text (Three Records, "Units", "Weight" and "Average")
And use a crosstab query that cross-joins to the new table and calculates a different value for each line like this:
Code:
Query4:
TRANSFORM Format(IIF(C2.CrossField="UNITS",Sum(SemUnits),IIF(C2.CrossField = "Weight",Sum(SemWeight),(Sum(SemWeight)/Sum(SemUnits)))),"0.00") AS TheValue
SELECT Q1.Index, C2.CrossField
FROM Query1 AS Q1, tblCross AS C1, tblCross2 AS C2
WHERE ( Q1.Semester BETWEEN C1.FirstSem AND C1.LastSem)
GROUP BY Q1.Index, C2.CrossField
ORDER BY Q1.Index, C2.CrossField DESC
PIVOT C1.CrossTitle;
Or, you could also change Query3 so that it calculates a formatted
Code:
Query3B:
TRANSFORM IIF(Sum(SemWeight)>0,Format(Int(Sum(SemWeight)),"00000") & " / " & Format(Int(Sum(SemUnits)),"000") & " = " & Format((Sum(SemWeight)/Sum(SemUnits)),"00.00"),"") AS TheResult
SELECT Q1.Index
FROM Query1 AS Q1, tblCross AS C1
WHERE ( Q1.Semester BETWEEN C1.FirstSem AND C1.LastSem)
GROUP BY Q1.Index
PIVOT C1.CrossTitle;