SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to sum on parent column but still display child columns


How to sum on parent column but still display child columns

Author
Message
Guru1
Guru1
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 21
Hi
I am new to SSRS. I could generate simple reports.
But I am stuck generating the following report.
I have a DataSet which gets the following data.

OfficeId OfficeResources GroupId GroupDesc
10 1000 G1 Desc1
10 1000 G2 Desc2
20 2000 R1 RDesc1
20 2000 R2 RDesc2
20 2000 R3 RDesc3

I want to create a report to display the above result in the following format
OfficeId OfficeResources GroupId GroupDesc
10 1000 G1 Desc1
. . . . . . G2 Desc2
20 2000 R1 RDesc1
. . . . . . R2 RDesc2
. . . . . . R3 RDesc3
---------------------------------------------
OfficeCount = 2 TotalOfficeResources = 3000

But I am getting TotalResources = 8000

Please ignore the "." Substitute it for a space. I used "." here in the post to better format my report.
I am grouping on OfficeId and OfficeResources in SSRS and not in the TSQL.
I used CountDistinct(Field!OfficeId.Value) for Count and I am getting count = 2, which I want.
I used Sum(Field!OfficeResources.Value) for TotalResources, so am getting 8000. which is not what I want.
I want sum on distinct OfficeResources to be 3000.
How can I achieve this.
Any help is really appreciated.
Thank you
Guru.
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)

Group: General Forum Members
Points: 62296 Visits: 13298
This MSDN thread offers some solutions:

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/3c2626d8-e835-4bba-b946-7d6796e9c617/sum-distinct?forum=sqlreportingservices


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search