SSRS Generate different table on each page - sql-server

I have built a report that has 2 sections populated based on a parameter. Once the parameter was chosen both sections populated correctly.
The sections are:
Title -> this is the parameter chosen from a dropdown
Department -> populated based on parameter
Division -> populated based on parameter
-------------------------------------------------------
System | Access -> table populated based on parameter
All the data is stored in one table; each Title has one Department, one Division, multiple Systems, Access.
I need to change the SSRS report to generate all the data at once without parameters, meaning it has to loop through each Title and populate the rest of the information, generating different tables on every page. Is this even possible in SSRS?

If necessary modify your query such that it returns all the rows for all the titles. Then:
Create a List which you group by the Title/Department/Division and show the Title/Department/Division using TextBoxs.
Create a Table within your List and reference the same dataset and it will automatically display the rows associated with the current group being displayed in the List.

Related

SSRS - 1 Stored procedure called executed multiple times

I have a report that returns the description of a product sheet from the product reference.
The product sheet contains: the description of the product, dates, the history of the product, ...
The data comes from a stored procedure called with a SINGLE reference.
The report criterion is currently a single reference.
So everything is ok.
I would like to pass a list of references separated by, for example, a comma and run the PS as many times as there are references to query and make as many product sheets as references.
I hope i was clear.
A big thank you for your answers.
It sounds like you already have a report that produces a result for a single reference. If that is true then the easiest way is probably to use your existing report as a subreport.
In brief...
You will need to create a new report, add a dataset that contains a unique list of references that you want to produce reports for (this could be parameterized too if required).
This might be as simple as SELECT DISTINCT RefID FROM myTable
Next add a list control to your report and set its dataset property to the dataset you created above.
In the list's 'cell' right-click and insert a subreport. Now right-click the subreport placeholder and set subreport to be the name of you original report. Set the parameter to be the fields from your dataset above (in this exmaple [RefID]).
The list will produce one subreport per entry in the dataset. You can set page breaks from the list control if required.
If this does not help, let me know and I'll update the answer with more details.

SSRS - Issue with blank table

I'm trying to build a report that will returns both a customers information and the services they received. So far how I've broken this report is for the customer information I added a "list" and then since I needed the headers on the left side (text boxes with text) and info on the right (text boxes converted to variables). I drug over each variable from my dataset1 individually.
The second box is a 2nd list with a table inside of it representing only the services performed for the customer from dataset2.
The problem I am having is if the customer exists it populates the 1st list but if they do not have any services then list 2 disappears and the only thing that exists is the customer information list.
Is there a way to still show the 2nd list with an empty table if no services exist for a current customer??
EDITED:
1st Pic - shows the 2 tables I've added to my report. Diagnosis table is in List1 and the Treatment Plan table is in List2.
2nd Pic - shows the refreshed report where data exists for the Diagnosis table but the table/list containing the Treatment Plan... is now missing since there is no data available to populate this table.

Passing MultiValue Parameter to Cascading Parameter in Subreport with SSRS

I have a summary report that passes information to a detail subreport in SSRS. The subreport accepts 4 parameters:
From Date (DateTime)
To Date (DateTime)
District (Multi-value String)
Item ID (Multi-value String)
The Item ID parameter is a cascading parameter that depends on the From and To Date. I am having an issue with the parameter not being set when values are passed from the main report to the subreport that are not within that date range. Take the following as an example:
Group Item ID
Banks ABCD 01
ABCD 02
ABCD 03
ABCD 04
The values above are defined in a setup table used in the main report. The idea is that the Banks group should have those Item ID's associated with them. Those values are passed to the subreport via the Item ID parameter. The problem is that when the parameters are passed to the subreport, not all of the Item ID's will necessarily be in the data for the given date range. In this case, SSRS does not select any of the Item IDs when the subreport is loaded.
Some additional information:
The Item ID parameter needs to be set up as a cascading parameter in this way because there are over a thousand different values and SSRS does not support more than 1,000 items in a multivalued list.
The table that both reports are using is a transaction table so the queries can be slow. I would like to avoid having to execute another dataset to determine which Item ID's are actually within the date range from the main report (since this is going to happen anyway when the subreport is loaded).
If all 4 of the Item ID's are available for the given date range in the report, it selects them correctly.
I was thinking it may be possible to create a running value type field that concatenates the Item ID's together to a string in the main report, then split it and pass it to the subreport. This would get the item id's actually used in the query without having to execute the query another time. I thought it may also be possible to trim out the values in the subreport if they aren't contained in the parameter value list? I'm guessing, if this is possible, I will need a hidden parameter to do this work then set the main parameter from the hidden parameter.
Any thoughts on how I can handle this situation? Let me know if you need any additional information.

filter data from one table based on second table without duplicates

Note: I'm working with a large complex database, so for clarity's sake I have simplified the set up below.
I struggled a bit with how to title the question since it's a bit of a complex question. I hope it's accurate enough....
A bit of background first:
I have an Access 2010 database that contains a one-to-many relationship between a table Called "Products" and a table called "Datasets" (ie I have a bunch of products, and each product has multiple datasets). Each has an autonumber key field (p_ID and d_ID respectively) as well as numerous other fields.
I have a form (lets call it frm_Main) that has two subforms: sub_Products (based on the "Products" table) and sub_Datasets (based on the "Datasets" table). On the main form I have a control ctrl_SelectedProduct which is linked to [sub_Products]![p_ID] to see which record in sub_Products is selected / has the focus, and the sub_Datasets subform is linked to this control so that it only displays Datasets records that belong to the selected Products record.
On the main form I also have a number of controls that I'm using for filtering the data in the subforms. For example, I have a control ctrl_Category. I have this control coded so that when the user changes the value of the control, a filter is applied that limits the records in sub_Products to only those that have a p_Category value equal to whatever is chosen in ctrl_Category. If the control is blank, it will show all records. All this works great when if comes to filtering based on fields in the Products table.
Now the problem:
My problem is that I also want to be able to filter based on fields in the Datasets table. For example, Datasets has a field called d_Status. I want the user to be able to chose the status in a control (ctrl_Status), and based on this:
1) sub_Products will be filtered to display only those Products records that have an assotiated Datasets record (or records) that has d_Status equal to whatever was chosen in ctrl_Status
then
2) when a Products record is selected in this filtered sub_Products, sub_Datasets will only show the Datasets records that has d_Status equal to whatever was chosen in ctrl_Status
I know how to do part2. But I have no idea how to get part1 to work. Since sub_Products is currently based on the Products table, which does not have the d_Status field, I have no way to filter it based on that field. Thus, I'm assuming my first step will be to change my setup so that sub_Products is based on a query that combines the two tables (or at least adds the d_Status field).
If I do that, however, I get duplicate Product records. I can't use the query's Unique Values property because if I have a product that has two datasets, one with status "Current" and a one with status "Archived", then those aren't considered duplicates, and the product info is there twice. If I don't have the status field displayed, it shows only unique products initially, but then I can't subsequently apply a filter based on that non-displayed field.
I also tried basing sub_Products on a Totals query in order to utilize the Group By functionality, but I still couldn't get it to work right. Even if I could I don't think that's the best solution, because you can only have 10 fields with Group By, and my Products table has more than 10 fields that I need displayed in sub_Products.
I feel like I'm now just going around in circles and am at a loss of what to try from here. Please help!
Couldn't you add something like this?
Private Sub ctrl_Category_AfterUpdate()
Form_frm_Main.Recordsource = "Select * from Products where p_ID IN(" & _
"Select p_ID from Datasets where d_Status = " & _
Me!ctrl_Category.Value & ")"
End Sub
Alternately, you can access the childform via the parent of the other child form.
This is a non-working snippet just to give you the idea:
Me.Parent.otherChildFormName.Form.Recordsource = whatever

SSRS parameters, populating the available fields list

When producing a list of available parameter properties, rather than manually typing each persons name in one by one, is there any way of just populating the data from the table/view which holds all the possible names?
I assume its in the circled box however all that does it let me point to a dataset and then field which I have tried selecting StaffName (being the field that is the one I'm using) if I then run the report it falls over.
Add a new dataset to the report, maybe called StaffMembersDS. The SQL for it might look like:
SELECT Id, Name
FROM StaffMember;
Then assign Name to Label and Id to Value.
BTW if this is related to your last question you're going to run into the trouble that when a user picks a staff member name from the drop down list they are picking only one value. So for your case you might want the Value field to be tied to Name as well as the label. That would allow you to use the query in your last question - SSRS Parameters - which collects related Id values.
SSRS's concept of a query is largely tied to a data set that you define in Report Data.
When you choose 'Use a query', you should be choosing a pre-defined query from Report Data. Of course, the good news is that you can define these yourself.
So let's take your example. You want your possible parameter options to be StaffNames.
Create a new dataset in Report Data. It should return all possible staff names for your report.
Something like:-
SELECT DISTINCT
StaffName,
StaffID
FROM
MyReportViewOrTable
Once you have defined this dataset, you should be able to use it as a source of parameter values.

Resources