sql - Add an overall average row to Report Builder report -
i need creating overall average in report builder 3.0. have query returns data in following format:
major       num of students     max gpa     min gpa     avg gpa ----------  ------------------  ----------  ----------  ----------- accounting  89                  4.0         2.3         3.68 business    107                 4.0         2.13        3.23 cis         85                  3.98        2.53        3.75 i added total row in report builder shows sum number of students, overall max gpa, , overall min gpa. can't run avg function on avg gpa column, needs take account number of students overall average. believe need following (in pseudocode):
foreach ( row in rows ) {     totalgpa      += row.numofstudents * row.avggpa     totalstudents += row.numofstudents }  overallavggpa = totalgpa / totalstudents does know how in report?
in case need weighted average here, in total row:
=sum(fields!numofstudents.value * fields!avggpa.value)   / sum(fields!numofstudents.value) you can see i'm creating expression fields!numofstudents.value * fields!avggpa.value each row, summing that, dividing total students.
in case give (89 * 3.68 + 107 * 3.23 + 85 * 3.75) / (89 + 107 + 85), i.e. 3.53, seems correct.
Comments
Post a Comment