Solved

How do I print an aggregate list of values in a group footer

Posted on 2008-10-06
4
208 Views
Last Modified: 2008-10-18
I have a column in the detail section of the report that flags the rows that meet certain criteria (example: "start date < currentdate").  In the group footer, I need to print the key value of the rows that got flagged or that met the criteria (example: 3557 Olson, 6593 Kent).  If I were doing the report in Crystal, I would create a shared variable that would accumulate the values as the rows were processed.  I don't know how to do a similar function in SSRS.  I wondered about RunningValue or Join but don't think these really apply to this situation.

Example of group contents with last column being the "flag" that indicates rows needing to be in list and the last line in the example being the "running list" I need to return:
Group: MN
2959   Grant   7/20/09    0
3557   Olson   9/15/08    1
3558   Jones  10/30/08   0
6593   Kent     8/15/08    1
6700   Tombs  12/1/08    0
MN Starts = 3557 Olson, 6593 Kent

Thanks
0
Comment
Question by:sanw2020
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
rob_farley earned 250 total points
ID: 22655888
Easy to do it in the query using FOR XML PATH('') for string concatenation. Should be doable in SSRS too, but there's no nice concatenation function.

So... if you want to do it in the query, try something like:

select *, stuff((select ', ' + cast(t2.id as varchar(10)) + ' ' + t2.name from table t2 where t2.group = t1.group and t2.flag = 1 order by t2.id for xml path('')), 1, 2, '') as concatbit
from table t1
order by group

Rob
0
 

Author Comment

by:sanw2020
ID: 22658730
Are you saying that I should create the concatenated string while creating the Data for the report rather that while working on the Layout tab of the report?  Or are you saying that I can create a formula in the group footer section and embed the sql string in the formula?  

Sandy
0
 
LVL 15

Expert Comment

by:rob_farley
ID: 22665137
Well, I'm saying that you have creating it in the DataSet as an option. I'm not saying you should embed SQL in the formula.

Of course, if SSRS had a concatenate aggregate function, then it would be simple.

Rob
0
 

Author Comment

by:sanw2020
ID: 22668869
Thanks again for your response.  I'll give your suggestion a shot.

I'm surprised that I have only had one responder to this question...  Is this a stupid question?  A very simple/basic question?  Or a very hard question?  

Sandy
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through setting up a JasperReports Server using the AWS EC2 instance, and this article will cover some basic administration tasks I had to perform.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now