Results of calculating with Sum (expression) give a wrong number in SSRS

醉酒当歌 提交于 2019-12-12 03:36:02

问题


I have a column which should calculate some numbers and sometimes it gives me the correct sum and sometimes it doesn't. I don't know why! Can someone please point me in the right direction?

I used this expression:

=Sum(Fields!TotalEmployees.Value)

When I don't choose something from filters on the top , it will give me the correct sum:


And when I choose something from the filters on the top, for example between 2 dates, it will give me wrong the sum:


Parameters & Body of report :

@EndDateFrom
@EndDateTo




回答1:


Yeah, you need to be wary of your grouping. I'm willing to bet you're stuck inside of a group which is filtering your results.

If you are using Report Builder 2016, you can right click your last row and select "Add Total". This will generally automatically generate a row that gets the sum of all fields in your group.




回答2:


i solved this issue with changing my query ,where all calculating (AVG , Sum &.. ) happens in query , instead reporting services do it for me .. after that i got the correct number:

SELECT t1.Departments, count(t1.id), avg(t1.age),sum(t1.TotalEmployees)/count(t1.id)
    AS TotalEmpl FROM (<current_query>) AS t1 <br> GROUP BY t1.Departments


来源:https://stackoverflow.com/questions/43001304/results-of-calculating-with-sum-expression-give-a-wrong-number-in-ssrs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!