Is there a way to do this with queries?

L

LAS

Below is the rowsource and two queries for a chart, where the categories are
Principle1, Principle2, Principle3 and Principle4. Everywhere else in the
application I am able to display less than four Principles, depending on a
parameter, principle_count. Is there some way I can eliminate the extra data
from my chart? For instance, if the principle_count is 3, I would not want
to see a category for Principle4.

Row Source

TRANSFORM Avg(qryBehavior.Score_Value) AS AvgOfScore_Value

SELECT qryBehavior.Period_Code

FROM qryBehavior

GROUP BY qryBehavior.Period_Code, qryBehavior.Sort_Order

ORDER BY qryBehavior.Sort_Order

PIVOT qryBehavior.Score_Type;

qryBehavior

SELECT qryMain.Student_ID,qryMain.Period_Code, qryMain.Score_Date,
'Principle1' AS Score_Type, avg(qryMain.Principle1) as
Score_Value,qryMain.Sort_Order

FROM qryMain

Group by qryMain.Student_ID, qryMain.Score_Date,
qryMain.Period_Code,qryMain.Sort_Order;

UNION SELECT qryMain.Student_ID, qryMain.Period_Code, qryMain.Score_Date,
'Principle2' AS Score_Type, avg(qryMain.Principle2) as
Score_Value,qryMain.Sort_Order

FROM qryMain

Group by qryMain.Student_ID, qryMain.Score_Date,
qryMain.Period_Code,qryMain.Sort_Order;

UNION

SELECT qryMain.Student_ID, qryMain.Period_Code, qryMain.Score_Date,
'Principle3' AS Score_Type, avg(qryMain.Principle3) as
Score_Value,qryMain.Sort_Order

FROM qryMain

Group by qryMain.Student_ID, qryMain.Score_Date,
qryMain.Period_Code,qryMain.Sort_Order;

UNION SELECT qryMain.Student_ID,qryMain.Period_Code, qryMain.Score_Date,
'Principle4' AS Score_Type, avg(qryMain.Principle4) as
Score_Value,qryMain.Sort_Order

FROM qryMain

Group by qryMain.Student_ID, qryMain.Score_Date,
qryMain.Period_Code,qryMain.Sort_Order;

qryMain

SELECT [last_name] & ", " & [first_name] AS Full_Name,
fncWeekStartDate([score_date]) AS Week_of, tblScores.Score_Date,
tblperiods.Period_Code, tblScores.Principle1, tblScores.Principle2,
tblScores.Principle3, tblScores.Principle4,
fncTotalPrinciplePoints([Principle1],[Principle2],[Principle3],[Principle4])
AS TotalScores, tblStudents.Student_ID, tblperiods.Sort_Order,
fncAveragePrinciplePoints([Principle1],[Principle2],[Principle3],[Principle4])
AS AverageScores, tblStudents.Class_Code, tblperiods.Description,
tblScores.Comments

FROM tblStudents INNER JOIN (tblperiods INNER JOIN tblScores ON
tblperiods.Period_Code=tblScores.Period_Code) ON
tblStudents.Student_ID=tblScores.Student_ID

WHERE tblPeriods.Period_Code<>'*'

ORDER BY [last_name] & ", " & [first_name], fncWeekStartDate([score_date])
DESC , tblScores.Score_Date, tblperiods.Sort_Order;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top