Dynamically update one parameter based on the value of another - sql-server

We have a report in SSRS 2005, where in we wanted to update one parameter(which is not linked to any other report parameters or dataset) based on the value of another report parameter(which is the selected value from a dataset). Can anyone let me know how to achieve this functionality?

This sounds wrong. If you have parameter A that is selected from a drop down, and parameter B that is typed in, you want to change B to f(A,B)? Instead, write your query to calculate f(A,B) and use that value.

Instead of trying to create a report parameter field that is filtered based on another parameter, create a report that produces the list of desired values. Make the values in the report be links to another report where the selected value is passed in as a new report parameter.
Or, depending on your situation, it may be better to do the same sort of thing as a web page. Create a page to let the user filter and select the desired values for the parameters, then pass them in to the report.

Related

How can I select all parameters to run a report, but have them run independently

My quality engineers have asked me to create a report based on a document that they fill out manually. At first glance, it appeared to be an easy enough request. It has been anything but easy. This report shows the results of two inspections and I have a parameter where the user selects one inspection or the other. As it stands now, this report runs just fine when selecting one inspection, but I am anticipating a request to be able to run the reports for both inspections at the same time. And, that's where I run into trouble.
The problem is that I have a text box in the header that is referencing a value from a table in the report that identifies the inspection. When I set the parameter to a multi-value parameter and select all, the report only displays one of the inspections across the entire report. Is it possible to have the user select both inspections but have the report run them separately? I have one dataset for the table and a column in that table that identifies the inspection. I have tried the multi-value parameter and I have tried using the filter option in the dataset properties, but I get the same result.
The easiest way to do this might be to create a new master report and use your current report as a sub-report. It's fairly simple.
Here's the basic steps...
Make a copy of your current report and rename it (say sub_InspectionReport)
Change this report so the the inspection parameter is NOT multi-valued
Create a new report and add your parameter(s) the same as you setup for your original report, This time make sure your Inspection parameter (e.g. pInspection) IS multi-valued.
Create a dataset (dsInspectionIDs) that returns a list of the selected inspection values from the pInspection parameter. The query could be something simple like
SELECT InspectionID FROM myInspectionTable WHERE InpectionID IN (#pInspection)
Note: #pInspection is the name of your report parameter, it is case sensitive.
Now add a table to the report and, as a simple, test, se the dataset of the table to your daatset dsInspectionIDs. Set the first column to show the only available field (in this example InspectionID).
Run the report and test the output using different inspection parameter selections. The table should match what you have selected...
We're almost there...
Now in one of the table cells (but not in the header) , right-click and select "Insert / Subreport". Now right-click the sub-report placeholder and set the sub report to be the copy of the original report we made at the start (sub_InspectionReport in this example). Now, still in the sub-report properties, go to the parameters tab and set the Inspection parameter to the the InspectionID field.
Now when you run the report, you will get your sub-report run once for each selected parameter value with that parameter passed to the sub-report.
Hope that makes sense, I'm not near my PC so I can't provide a sample with images at the moment.

SSRS: Dynamically Creating New Matrix

I have the following format in my dataset (see Dataset Layout screenshot).
I need this report to show like the following (see Report Layout screenshot) with a bit of a difference, but first let me explain.
This report is a "monthly" report that shows the data for each day of a given month. What I have shown in the Report Layout screen shot is how the report displays if the user only selects one available value for column "Level!2!Sample". So in other words, instead of seeing multiple values in that column as shown in the screen print, it would only contain one distinct value. This report works when only one item is available, but I need to allow for multiple options.
What I need to do is be able to display data like this for multiple values of "Level!2!Sample", and each time a new "Level!2!Sample" is encountered, it would create a new matrix as shown in the screen print. So if there are four distinct items for this column, I would have four different tables shown on the report, each displaying the data for the given distinct value of the "Level!2!Sample" column.
I assume I would need to use an "Order By" clause to get my data looking correctly:
Order By
Level!2!Sample,
name!3!Title,
month!4!ReportMonth
But I am not sure how to get SSRS to create a new matrix when the new level!2!sample record is encountered.
I hope my explanation makes sense as to what I am trying to do. Any help is greatly appreciated.
You can't create a new matrix like that but there are other options.
Simple option: Create one big matrix grouped by Level!2!Sample and have page break between groups. This would obviously mean you would end up with 4 pages in your sample scenario which may not be ideal.
Slightly less simple option:
Create a new report
Include your parameter as you did for the current report.
Add a dataset (let's call it dsLoop) that returns a single column and 1 record per selected parameter entry. This might look something like SELECT DISTINCT Level!2!Sample FROM myTable WHERE Level!2!Sample IN(#myParameter).
Add a table with a single column and a single row and set it's width to the width of your report/page.
Set the dataset for the table to be dsLoop
In the table's cell insert a subreport and set the subreport properties to point to your original report
Set the subreport parameter to Level!2!Sample from your dataset.
Notes:
a. You can get rid of the available values and related datasets from your original report as these are no longer needed (optional)
b. You can add rows before or after the cell with the subreport if you want to add gaps between each tablix.
Basically your new report acts as a loop and creates one row per selected item in the parameter list, each row contains an entire subreport with the parameter for the current row passed to it.
The net result is that you will get a 'new' table for each selected entry.
Hope that makes sense.

SSRS - Report Based on Parameter Selection

We have a web based report we are moving to SSRS. In the SSRS report, I need one report to be able to call three different stored procedures based on the selection of a parameter value, and the output / report display would also be different.
I believe I can create three different datasets for each procedure but I don't want all three to actually run when the user selects "View Report", as that would be excessive execution.
How could I get only one procedure to be called and only the correct report section to show based on the parameter?
Let me try and give an example if the above doesn't make sense:
Parameter: Report Type
Values: Day / Month / Year
If the user selects "Day" for the report type parameter, I need to call "SP_ReportDay". If the user selects "Month", I need to call "SP_ReportMonth" and if the user selects "Year" I need to call "SP_ReportYear".
Each report type would have different data displayed. It isn't the same columns for ecah report and the data displayed is different.
How would I show / hide sections based on the selection criteria along with calling the correct procedure?
If the result sets are different, you don't have many choices besides running all three sprocs. BUT you can add a parameter to each sproc that tells them, respectively, not to actually return any results. Your report can set this parameter at run-time. You'll have to modify the body of your sprocs accordingly.

SSRS Drop Down List Values

We have a report in SSRS that has drop down list parameters that are fed by a shared datasource and query.
If I use ReportViewer to view the report these work as expected.
However, I'm also using the SSRS web service to pull out the parameters and the available values. In this instance when drop downs are moved from a manually entered list to a query the available values list is empty.
I'm assuming the problem is because the web services simply gropes the RDL file and does not execute the queries attached to the parameters.
My question is, is there any way to have it do this or to get the available values?
After reading MSDN it seems the answer is to call GetReportParameters() and set ForRendering to true:
If ForRendering has a value of false, the parameter meta data returned represents the parameter data that is currently associated with the specified report. If any parameters values are based on a query and you are interested in returning the query-based parameters valid values list, you need to set ForRendering to true, In addition, for query based parameters, you need to ensure that you have passed in all of the credential information required to return the query parameters.

SSRS: adding a Matrix based on 2 DataSets

I just started working with SSRS, and figured out how to connect my MDX Query to a Cube and plug that into a Matrix
However, i need to have a matrix, and in each section, i need to call a different DataSet.
For example:
Matrix1 would have a repeating section based off DataSetA (let's say its customer centers).
in each section (customer center) of Matrix1 i would have a Expression, which calls DatasetB, using a value from DataSetA as parameter (let's say it would be a separate MDX query getting some other information based on customer center ID).
so my expression from within a tablix cell is something like this:
=First(Fields!MTD_Trades.Value, "DatasetB")
is it possible to pass a MDX query filter (or where clause) using a parameter from this point?
ideally it would be something like this (pseudo code):
=First(Fields!MTD_Trades.Value, "DatasetB") WHERE Fields!Where_Filter.Value
something along these lines.. where the MDX WHERE section is dynamic based off another query
UPDATE - solution explanation
here is an example of what i am doing: Let's say the application is based on air traffic and the business user here is some aviation authority person. I will give that person a UI that will let them define the slices they want to see. For example they can come in, and create n slices (i.e. International Flights, Flights leaving US, Flights Arriving After Midnight, Flights with 50+ passengers... n). As you can see, they will have the freedom of adding any filters they wish to each slice.
Then based on their actions (using GUI), i will generate the necessary MDX queries (one for each slice).
My challenge here is to create a SSRS report that will show a separate line for each one of those slices (1-n). Hope that helps in understanding my conundrum. The first part of the query will be the same for each slice (# of flights), but the WHERE section will be different and dynamic for the report.
You can use the lookup() function to access data in another dataset from within a reportitem but you cannot run multiple sub-queries within the report. You can only do this within the parameters where one parameter can be an input for another query driven parameter.
The best course of action is to modify your original query to contain all the data you need for the Matrix.
EDIT: It sounds like you need to use a multivalue parameter.
In the "Slices" parameter set it to allow multiple values
In the dataset which accept this parameter, goto the parameters form and set the value to an expression which is =Join(Parameters!Slices.Value,",").
Pull apart the string in you query and run each subquery then return as a set.

Resources