I am trying to show a line graph of RunningSum(Goal) vs RunningSum(Actual) over time.Here's the query I'm using as the basis of my report (which may be the issue):[code="sql"]SELECT EnrollmentGoal.ProtocolNo, EnrollmentGoal.WeekNumber, EnrollmentGoal.Goal, COUNT(Enroll.enrollmentID) AS EnrollCountFROM Protocol INNER JOIN EnrollmentGoal ON Protocol.ProtocolNo = EnrollmentGoal.ProtocolNo LEFT OUTER JOIN Enroll ON EnrollmentGoal.ProtocolNo = Enroll.e_ProtocolNo AND EnrollmentGoal.WeekNumber = Enroll.PWeekGROUP BY EnrollmentGoal.ProtocolNo, EnrollmentGoal.WeekNumber, EnrollmentGoal.Goal[/code]Is my best bet to create a CTE to calculate the running total and then base the graph on a dataset that runs that stored procedure? (starting to think so).The problem is that although I can [u]calculate[/u] the running total in SSRS, it does not appear to be a column that I can actually use in my graph.Would I be better off using a CTE as the basis of my report and doing the running sum there?FWIW, I tried this... and it's close, but I wanted the renumbering to restart after the ProtocolNo changes:[code="sql"]-- this is close, but I wanted to break on e_ProtocolNoSELECT TOP 150 enrollmentID, e_ProtocolNo, PWeek, RunningTotal = COUNT(enrollmentID) OVER (ORDER BY e_ProtocolNo, PWeek ROWS UNBOUNDED PRECEDING)FROM enrollWHERE e_ProtocolNo != 'BRE150'ORDER BY e_ProtocolNo, PWeek;[/code]
↧