tsql - Calculating Sum and average in SSRS -


i problem in report. have matrix goes this


                     |id   |           |question(text)|    |point(value)|   |calculated(average)|   |calculated(satisfaction)%|                   summary:            |average(average)   |   |average(satisfaction)%| 

this matrix inside group page group.

so, question in 1 of page groups,

the question_text blank , in tern point(values) 0.

the average per row showing correct value summary average not show correct considering row , calculating average.

so if sum of averages 40 , there 4 questions (including blank question) average 10 instead of 13.33 divides 4 instead of 3.

that row displayed due query , need change query or there way can in ssrs itself.

you use expression excluding blank questions:

=avg(iif(fields!question_text.value = "" or isnothing(fields!question_text.value)   , nothing   , fields!point_value.value)) 

or alternative:

=sum(fields!point_value.value)   / sum(iif(fields!question_text.value = "" or isnothing(fields!question_text.value), 0.0, 1.0))'updated 

edit after comment:

i added expressions report - first worked fine , second worked fine after minor update (see edit details).

i created test dataset following query:

select question_group = 'group1', question_text = 'q1', point_value = 10 union select question_group = 'group1', question_text = 'q2', point_value = 15 union select question_group = 'group1', question_text = 'q3', point_value = 15 union select question_group = 'group1', question_text = '', point_value = 0 union select question_group = 'group2', question_text = 'q4', point_value = 10 union select question_group = 'group2', question_text = 'q5', point_value = 15 union select question_group = 'group2', question_text = 'q6', point_value = 15 union select question_group = 'group2', question_text = null, point_value = 0 

i created group based on question_group , added both expressions group footer.

report in design mode:

enter image description here

report result based on above dataset:

enter image description here


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -