How to parameterize DataSet with group variable? - reporting-services

I have 'external' table.
Inside each row of this table I need to show several tables associated with different DataSets.
But I have no idea how I can constrain these 'internal' DataSets with parameters of the group.
Is it possible?
Update
The next step may be to show subreport.;) The problem is that when nested DataSets have empty results subreport is not shown... even static content.
Here is a nice post hot to force subreport to appear.
The idea is simple. You need to add fake DataSet to subreport with query like:
select ' ' as Dummy
and use the result in visible textbox like that:
=First(Fields!DUMMY.Value, "DataSetToForceSubreportVisibility")
It works like a charm.

Yes, this can be done with sub-reports.
1) Create a report, which contains all the "internal" tables you want for each row of the "external" table. Populate it with a dataset that has an ID parameter for which member of the outer group this is, so that all the internal tables will only be about a single group member.
2) Create a main report for your external table. This report contains a List control, and you populate it with a dataset that gets the members (IDs) of your outer group.
Inside each cell of the list is a subreport, which is the report you created in 1). You pass to the ID parameter of the subreport the field containing the IDs you selected for the List control.

Related

Create Multiple Tables according to a list input in SSRS Reports

I'm new to SSRS Reports.
I have an SSRS Report that takes a list of category Ids
And I stored procedure that called SP_GetProductsByCategory that takes categoryId
I want to create the tables dynamically according to the list.
If it takes 3 Ids , a 3 tables will be create with 3 procedure calls.
This is fairly simple to do using subreports.
First create a report (let's called it singleCategory) that accepts a single categoryId as a parameter (call the parameter pCategoryId for example). Setup the report so that it produces the table you require but just for this single category.
Once that is done, test it and make sure it's working as expected. Remember this should only accept a single categoryId.
Note:
I'm assuming your users will select categories from a database driven parameter list...
Next, create a new report (e.g. CategoryMasterReport) and add a dataset (dsCategories) to get a full list of available categories for the user to choose from. This might be something as simple as SELECT categoryId, categoryName FROM myCategoryTable.
Next, add a parameter (pCategories for example). Make this a multi-value parameter
Set the available values for the pCategories parameter to the dsCategories dataset and choose label and value columns as appropriate.
Now create another dataset, this one will list all the categories selected by the user. Call it dsSelectedCategories and set the query to something like...
SELECT categoryId
FROM myCategoryTable
WHERE categoryId IN(#pCategories)
Next, add a table to your report and set it's DataSetName property to the name of the dataset we just created (dsSelectedCategories). We only need one column in this table so you can remove the rest. You can also remove the header row.
In the table's remaining textbox, right-click and choose "Insert ==> Subreport". This will fill the textbox with a subreport placeholder. Right-Click the subreport placeholder and choose 'subreport properties'.
In the general tab set the subreport to be used as the one we created at the start of this (e.g. singleCategory).
In the parameters tab, click 'Add' then either choose the name of the parameter from the drop down list or type it in (following the example names from earlier this will be pCategoryId). For the value property, click the drop down and choose the categoryId field (if you followed closely this might be the only field listed.
That's it.
Now run the main report (CategoryMasterReport), select some categories from the list and you should see a table for each selected category.

Generate 1 report based on multiple executions of stored procedure (passing different parameters to same procedure)

I have a SSRS report that takes a parameter and executes a stored procedure to generate a report with it.
the parameter is a values from a table that I have user select from a dropdown
let's say 15 options that are passed as parameters to each execution.
AAAA
AAAB
AAAC
...etc
is there any way I can setup the report so it will execute with each parameter and generate a report?
the issue is that now the user has to manually select 1st parameter, generate the report and then export the file result to excel.
what I want to do is a way for the user to select multiple parameters and export just one file containing all of them (the stored procedure can't take more parameters because of the way is coded depends on receiving one parameter only)
so it would have to schedule multiple executions of the stored procedure to create the report and then export this. is this possible? (as a note, the amount of parameters will change frequently so I need to give the option of selecting multiples from a list that is populated from a query to database)
and to clarify, the Stored Procedure needs to take only one parameter, this is not to be solved by sending multiple parameters to operate by using a splitter or similar, as the parameter received by the SP is used in calculations depending of order, (to not go into detail with the SP, just need to take one parameter per execution)
As you already have a report that handles a single option then you can do this easily using sub reports. Don't worry about the length of this answer it actually quite simple.
I would make a copy of the existing report to be safe....
Change the existing report to only accept a single parameter value if if doesn't already. Save this report, this will be your sub-report so let's say it's called mySubReport
Next create a new blank report.
Add a dataset (called say dsParameterList) that will give you the list of options you want the user to choose from (I guess this will be the same as your current report?). For example if it was a list of companies it might look something like SELECT CompanyID, CompanyName FROM myCompanyTable
Next add a parameter called say #options, make sure it is set to be multi-value and set the available values to use a query and point this to dsParameterList. Set the value and label fields as required.
Now create another dataset called dsLoop for example. This dataset will contain a list of selected parameter values. Using the company example from earlier the dataset query might look something like this. SELECT CompanyID, CompanyName FROM myCompanyTable WHERE CompanyID IN (#options)
Next add a table to your report and remove columns so that only 1 remains. Set the dataset property of the table/tablix to dsLoop. This means we will generate 1 row for every selected parameter value.
In the detail row right click in remaining textbox and choose 'Insert Subreport'. Now right-click the subreport placeholder and set the properties to point to the report we saved earlier (mySubReport in this example).
Whilst still in the sub report properties, click the parameters tab and add a new entry, choose the parameter in the left column and set the value in the right column to be the value from dsLoop that you want to pass to the subreport. In our company example this would probably be [CompanyID]
That's it. You run the report and choose from the parameter list, when you click View Report the dsLoop query runs and gives us a list of just those selected Companies, the report body is generated with a row for every row in the dsLoop dataset which in turn runs the subreport with a different parameter passed in each time.
Optionally You can right-click the rowgroup under the main design window and set the 'pagename' property to a value. In the Company example this might be =Fields!CompanyName.Value. When the report is exported to Excel each sheet in the workbook will be named with the name of Company

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.

SSRS Create As Many Tables As Needed (Using One Dataset) Based on a DataSet Field

I have a query that returns relevant data about inspectors and how long it takes them to respond to issues. The only parameters are a BeginDate and EndDate so for any given date range there could be anywhere from 0 to 100 inspectors.
I am using only one dataset and it contains an "Inspector" field that I'm hoping can be used as a filter to create as many tables as there are inspectors.
I know you can set filters on tables but from my (limited) SSRS knowledge, you must already have the tables created and the filters are typically hard-coded. What I need, is some way for the report to see how many Inspectors there are in the dataset and group those records into their own tables, repeating the same one created tablix over and over as needed.
This is being done strictly in SSRS 2012, not using a ReportViewer where back-end code could help me out unfortunately...
I don't have any code examples to provide, like I said I know you can do filtering but I am at a loss when it comes to doing something like this dynamically based on data... Sorry.
Depending on the report design you could either...
Single report with grouping
1. Create a single tablix.
2. Create a row group by Inspector and then add whatever fields you need to the details section.
3. You can optionally set page breaks between instances of your Inspector rowgroup from the rowgroup properties.
Sub report method
1. Create a subreport that accepts a parameter (InspectorID for example).
2. In the subreport filter the dataset using the parameter passed in so it only return data for a single inspector.
3. Add whatever controls you need to the report to handle a single Inspector
4. Create a main report
5. Add a dataset that gives you a simple distinct list of Inspectors, this will be used to pass parameters to the subreport.
Lets assume it just contains a list of InspectorIDs.
6. Add a list control to the report and set it's dataset property to the dataset that contains your list of InspectorIDs
7. Right-click in the list control's 'cell' and insert a subreport.
8. Set the subreport property to the subreport you created earlier and set that parmameter IsnpectorID to your InpsectorID field.
This will produce a subreport for each instance of inspector it finds.
Sorry about the format of this answer, in a rush!

SSRS New page per selected Parameter

I have a report which uses 3 datasets and on the report a am using Multiple Tables and Textboxes and expressions. When I run the report I have to select a Parameter which in this example is 'City'.
I want a new page for each City (parameter) , I have read to use page breaks and grouping but I selected a List from the toolbox and put that on top of my report, selected 2 'Cities' and expected it to return 2 pages but it returned 49 pages (majority blank)
I want a separate page per city how can I achieve this?
Thanks
If I understand you correctly (it difficult to be sure if you don't post your current design) then you would be better using subreports.
I'm assuming Cities are in a table in your database and each have a unique ID. If you only have the names then you can use CityName inplace of CityID and it will still work.
Create a new report.
Create new dataset (say dsSelectedCities and the set dataset query to something like ...
SELECT CityID, CityName FROM myCitiesTable WHERE CityID IN (#CityParameter)
This will automatically generate a report parameter called #CityParameter. Set the available values etc just the way you did in your original report, so if you need to add another dataset for this then do so. In this example I've assumed labels will be CityName and Values will be CityID. Whatever goes into the Values is what will be passed to our subreport.
Now add a table to you report, it only needs to be one column wide and one row long so just remove any other rows and columns just make sure you leave the detail row and not the header.
Set the dataset for the table to be dsSelectedCities
Make this remaining cell with wide enough to accommodate your subreport (which will be the report you originally wrote).
In the cell, insert a subreport
Set the subreport properties to point to your original report and set the parameter to the CityID field.
This table will act as a loop, for each record found in dsSelectedCities it will give us one row. As each row will have a single CityID we are passing that to the subreport, the subreport in turn just shows one City.
Set the page break option on the details group to break between instances.
You will probably have to modify your original report to accept a single CityID, it depends on how it was designed but hopefully this should get you going.
If this is unclear then post your current report design including all the details about parameters and I'll update the answer.