Bi-directional Parameter issue in Report Builder - sql-server

I have two task in hand to achieve in a single report.
Application URL filtering - One ListID will be passed in the URL to filter the report. I achieved this by having #id as parameter for my datasets. In this scenario I only had one parameter in place.
Reporting Server filtering - For users who don't have access to application/db, they can go to the Reporting server and Select a 'ListName' from a dropdown parameter(#ListName) that fills the List ID parameter.
I achieved this scenario by cascading parameters and having two datasets one for independent dropdown parameter(ListName) another for dependent parameter(ListID).
But since I cannot filter the report based on ListName from the application, I need a way to achieve both in the same report. When I try to filter the report using '?id=123' from application URL it does not filter the report.

You don't need two parameters, you are only ever need to filter on ListID so this is the only parameter you need. You only use ListName to look up the ListID.
Let's say your dataset for the list parameter values looks like this:
SELECT ListID, ListName FROM Lists
Link this Dataset to your ListID parameter's Available Values.
Parameter objects have a Value property which is used to run the query and the Label property which is display the list names to the user. Map ListID to the Value and ListName to the Label.
Now the application can simply provide a list id to the report. However, when a user runs the report, they will see the list names. When they select one, the corresponding ListID will be provided as the report parameter Value.

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 Generate different table on each page

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.

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.

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.

Order data using values stored in another table

I've been using cakephp for a while, but have not learned all the ins and outs yet so I may be missing something simple. Or the problem may lie with my database structure. Either way, if anyone has any idea of what I'm doing wrong, please share.
Is there a way to order the data returned by cakephp's find using values stored in another table?
I am creating custom form fields on a per category basis, so when I choose a particular category to post in, custom fields will be added to my form. I have 3 tables: Posts, Fields, and Answers. The Posts table stores the basic static information for the post, such as id, category_id, title, and description. The Fields table stores the custom field data, such as category_id, field_label, field size, etc. The Answers table stores the values that are entered for particular fields, such as post_id, field_id, value.
I am trying to display the posts for a particular category, and create html table headers on the fly, using select fields, set by a column toggle in the fields table, and also select the answers associated with that particular field and post.
I am able to select all the data I want, and paginate everything just fine, but what I can't seem to figure out is how to order the data using one of the dynamic column values. For example, if I have year, make, and model as 3 custom fields, I would like to click the year column to sort my results by the year values, and if I click the make column, I would like to sort my results by the make values, etc.
I know how to order the results by a particular field inside the posts table, such as id or title, but is it possible to order using the custom fields? Am I setting up the database and/or something else wrong, and if not is there are particular cakephp method or sql command that I need to use in order to sort by the custom fields? I'm not really well versed in complex sql commands.
Thanks.
I'd suggest you pass the field name and sort direction in the URL (GET param). So when you have your table header link, form it so that it links to a URL as so:
http://somesite.com/pages/index/sort:customfield1/dir:asc
Then when you're grabbing the data from the db in your find() query, include the named parameters as the order parameter that can be sent to find.
You'll need to determine a default sorting column and direction. Maybe have that be selectable with a boolean field in the schema -- if there are no parameters sent to the action above, pull the field from your other table that has default set to true in the record.
To clarify: when a user visits a given action, first you'll pull the custom fields from the other table. Then using those fields (either the default as mentioned above, or the named params passed in the URL) form the query for the actual data, using the order parameter.

Resources