How to populate an rdl table based on data returned from a query? - reporting-services

I have absolutely no experience working with rdl files and I received a ticket from a client asking us to display multiple reports in one report. What I have done so far is created a master rdl file that contains a sub-report. That subreport is linked to another rdl file which is the actual report that is normally generated. What I want to do is generate a list of those subreports based on the data received in an array from a query. So if there are 6 elements in the array then I need to have 6 subreports generated, with each report using data from the appropriate index in the array.
I managed to figure out how to connect the data for one subreport but I have no idea how to scale that programatically.

The basic steps are
Create a subreport that accepts parameters (done I guess)
Create a master report (done)
Create a dataset in your master report that contains a row of data for each subreport. For example. If you subreport showed employee details for a single employee, your main report might contain a dataset that lists employee IDs for a department.
Add a tablix to your main report, remove header row and leave only a single column. Stretch this column to fit your report width
Set the datasetname property of the tablix to the name of your dataset, (now it will produce one row per employee)
Right click the tablix cell and insert subreport
Right click the subreport placeholder -> properties then choose your subreport form the drop down.
Set the subreport parameter(s) to be the values from your dataset (e.g. EmployeeID = empID)
That's it.
You main report will run, the tablix will create a row per record in your dataset, this in turn will give you a subreport per row in your dataset, each of those subreports will have the value of the field from that row passed to it.
If you need more help, I'll try to track down a similar answer I posted a while back which had more detail.

Related

How to print out an SSRS report for each customer on the customer dropdown list

We have an SSRS report which takes customerID as a parameter, and we would like to print out a report for each of the customers on the Customer dropdown list. However, there are a few hundreds of customers on the list, and we are not able to go through each one manually. Is there a way to have the report automatically go through the customer dropdown list and generate a report for each customer, so we can print out the report all at once on our end?
You can do this a few ways. As you already have a report that does a single customer then it will be easy to use this as a sub report.
Note that this, as with most options, will give you a single report containing everything, it will not give you actual individual reports..
So, Create a new report. Create a dataset (say dsCustomers) that contains a list of CustomerID's that you need to report from. This dataset could be a simple query such as SELECT CustomerID FROM myCustomersTable for exmaple.
Now add a table to your report and set it's dataset property to dsCustomers.
Remove the header row from the table as we don't need this and remove all but one column so you tablix is just a single textbox. Make this textbox wide (it's doesn't really matter how wide, it's just to make things easier to see)
Now in the remaining textbox, right-click and choose "Insert => Subreport"
Right-click the subreport placeholder and choose "properties"
Now set the subreport to your original report.
In the parameters section add a parameter entry for your subreport's parameter. Assuming the subreport takes a parameter called CustID then select CustID from the drop down. On hte right side, the parameter value, set this to the name of your dsCustomers dataset field (in this example it would be CustomerID)
That's it...
Now when you run the report, the tablix will produce 1 row per CustomerID,, each 'row' will contain the subreport.
You will probably want to set page breaks on the rowgroup too so each customer starts on a new page.

Can you link multiple tablixes on a key field in a single SSRS report?

I am creating a report in SSRS to show evaluation scores. It has three sections, and I need to link them all together on the PreceptorID field (2108 in this case). The top two sections are from the same query. I am filtering the results in each one to separate the counts because they have different column names. The third section is a subreport showing comments from evaluators. It also has the PreceptorID field in the data but is not displaying it. It has two parameters that should be populated by the main report query, but that does not appear to be happening. The report is returning all comments instead of only the ones with the matching PreceptorID.
This first image is from Crystal Reports showing how the finished product should look.
This is what I am getting from SSRS. It is showing counts for multiple people at the top. The counts in the middle are actually correct. They are all for the one person. The next person's counts are on the next page. The comments at the bottom are also not filtering on the one PreceptorID.
This image showing the subreport parameter that should be linking it back to the main query.
How can I tell all three sections to only return data for the same person on one page, and another person on the next page?
I would redesign the report structure slightly. This is only my personal preference, there are several ways to achieve this but I find this way easier to manage and maintain.
You'll need two subreports and a master report.
You already have the 2nd subreport so no extra work required there.
I would take you current report, strip out the link to the current subreport and change it so it only processes a single person (just like your existing sub report).
So SubReport1 will have the two tables from your current main report only. It will only accept a single person as a parameter (or pair of parameters in your case)
SubReport2 will be your current subreport. Again it only accepts a single person.
Next create a new report. This will be the master report.
Add a dataset that contains just enough info for list of people you want to report over. So the dataset query might be as simple as
SELECT PreceptorID, ClerkshipID FROM myTable ORDER BY PreceptorID
Add a table to this report and set it's dataset property to the dataset you just created.
Change the default (details) row group to group and order by whatever makes each record unique (maybe both the two columns listed above, may only one will be required, only you will know this).
Right-Click on the row header to the left of your table and do "Insert Row => Inside Group Below".
Remove all but one column
You should now have a table with 2 rows per group.
Right click the top cell in the group and do "Insert => Subreport", go to the subreport properties and point this to SubReport1 (or whatever you called it) and set the parameters has you have done previously.
Repeat this for second row, this time pointing to your second subreport.
In the row group properties, set page breaks to "Between each instance"
That should be it. This was done from memory so might not be 100% but based on the info in your question you should be able to work it out from here.
Things to check if this is not working
Open each subreport and test it by passing in parameters manually. Each subreport should only be returning data for a single person.
The master report should have a dataset that returns each person once i.e. if there are 10 people in total this dataset should only contain 10 rows.
The table in the master report should contain only two rows
Both rows must be EITHER within the same row group, or, if you have no other row groups, they will both be in the detail row group.
The report design should look something like this if you have a row group by person
or like this if you only have detail rows.
Finally, make sure the parameters you pass to your subreports are the Field values from your master report's dataset, NOT your master reports parameters.

Generate single report for multiple user using SSRS

I need to create student certificate using SSRS. I created new .rdl file did designed and associated with data source.
It works for single student as expected. But it does not creates report with multiple certificate while my data source returns multiple student details.
I am new for SSRS, please help me out to achieve this.
If you want to generate a certificate for each row of your dataset in the same report, you can do this with a tablix:
Add a Tablix to you your report that lists your dataset data
Drag a Rectangle into one of the Details row cells
Make the cell you dragged the Rectangle into large enough to hold all your
certificate report items
Select all your certificate items and move them into the Rectangle
Update any references to your dataset to not include a 'scope'
ie: Change =sum(Fields!ColName.Value, "Your Dataset") to =sum(Fields!ColName.Value)
Run the report
You should now have a certificate for each row in your dataset.
If you want to export multiple separate certificates, you will need to set up a data driven subscription on your report, that runs it once for each row of a returned dataset. Obviously you will need to adjust your report to be able to receive which student to generate the certificate for as a parameter.
Another way is.. if your data set is returning one row per student, then all you need to do you on your tablix is to add a parent row group.. group on StudentID.. or something unique per record.. go to group properties and add a page break at end of group. This should generate one certificate page per student..
You may need to adjust group headings and footer and things like that appear.. You will figure it out... alternatively.. watch a youtube video on how to do a basic ssrs report.
I have a subreport call StudentSub.rdl. This is linked with DataSet (stored procedure) Sp_GetStudentName(#ClassNo int). This works fine it gives always only one certificate.
Since I wanted to generate class wise certifiacte, in that case I wanted to get muliple report page wise in one PDF file. Followed below steps:
Created new RDL file called StudentReports.rdl
Linked with same data set stored procedure Sp_GetStudentName.
Drag a table from tool box to design body.
Set visibility False for table Header and some columns except one td.
Right clicked in that box (td) and inserted sub report
Right clicked sub report properties selected StudentSub subreport.
In the sub report properties added parameter ClassNo then clicked Ok.
Now When I am previewing this StudentReports by passing class no. I am getting correct number of pages.
Hope this will help others.
Thanks!

SSRS Report - using the value from the subreport in a calculation in my main report

I am writing an SSRS report using report builder and have my main report and a sub report - I have had to do this because one of the figures is in a different table. The main report shows a customer column an amount column then my subreport column - in the next column I need to show these two figures added together, there is then a further column with another figure in and the final column will deduct the fourth from the calculated third - I dont know how to write an expression which incorporates the subreport value.
You can't retrieve values from a subreport like you wish as that's not how subreports work.
When you run the SSRS report, the parent report passes parameters to the sub-report (the only data transfer between the two), the subreport is rendered and then the rendered subreport is inserted back into the parent report as the parent report is rendered.
As I see it, you have two options to tackle the problem.
1) Join the data from the two tables in your source query so that all the appropriate information is within one dataset in your report.
2) Use the Lookup function to retrieve values from the second dataset. This is a very flexible option and one that I highly recommend that you review for scenarios like this.

SSRS 2008 R2 Subreport Displays Only on First Page

Long time browser of this site, but first time poster. Normally I'm able to find the answer I need by searching, but in this case I haven't been able to, and it's driving me nuts!
I'm using BIDS / SSRS 2008 R2 to create a membership renewal form which my business will mail out to our customers. The form contains customer information, including membership dues / subscription info and other billing details.
In order to accomplish this,
I have built three RDLs:
Main report (this is one the users run). Contains base data set
(let's call it Proc 1), which requires an expiration date only, to
pull a list of member IDs and corresponding physical information
(address, phone, membership type, etc.) Contains the first subreport,
in a list, grouped by member ID.
One subreport for the first page in the main report. Contains a
set of parameters for each field it needs. Rather than execute Proc 1
again, I pass Proc 1's output from the main report to this subreport.
Everything in this subreport is also contained within a list, grouped
by member ID parameter (passed from main report).
Another subreport, nested within the first subreport, which pulls
subscription information. First subreport passes member ID and paid
through date to detail data set in nested subreport (let's call it
Proc 2). Proc 2 requires paid through date from page one subreport,
and ONE member ID, which it gets from its parent report. It displays
this information in a table, not grouped, since it should only be
receiving one ID at a time--- being that its parent subreport. and the
main report. are already grouped. However, I have tried grouping the
table based on member ID, and it didn't make a difference.
I found this approach necessary, because of the fact that I had two write two separate stored procs: one to pull the basic data, and one to pull detailed billing data. It's impossible to combine the two without creating duplicate rows. And of course, it's not possible to have a tablix assigned to a different data set than the list it is contained within. Hence the need for a subreport. I hope that all makes sense.
Anyway, my issue is that the nested subreport only displays data for the first customer. In fact, it doesn't display the nested subreport AT ALL for the rest of the customers. It's as if the nested subreport is only being passed the first member ID, but I don't see how that's possible given the grouping? Note that I am not using any FIRST or aggregate functions in the proc or report expressions. And I can execute each report file just fine individually.
I have tried creating a dummy data set in the nested subreport (ex. SELECT 'Nothing' AS Nothing) and adding it to a text box, thinking that this would force the nested subreport to display, but it STILL doesn't. Thoughts on what I might be doing wrong? Thanks in advance.
https://social.msdn.microsoft.com/Forums/en-US/9f8b9c42-90cb-4620-ad91-9754029ed4db/seemingly-random-error-subreport-could-not-be-shown-in-a-report-with-nested-subreports-ssrs?forum=sqlreportingservices
Your nested subreport could be throwing an error that your not seeing.
Quote
The known issue in SQL Server 2008 Reporting Services described in http://support.microsoft.com/kb/967749 should be fixed in SQL Server 2008 R2. Generally, the issue occurs because the parameter value is not passed to the subreport correctly or the subreport is not valid due to the specific values passed to the subreport.
I think you should add a detail group then put the subreport in that cell. Make sure the grouping is working correctly and pass the right values to the subreport.