Populate a parameter dropdown based off another parameter - reporting-services

I am trying to populate a dropdown based off another dropdown parameter. I have 5 parameters, but the first 3 populate the 4th in the report. So the 4th and 5th parameter are what the user uses to populate a report. So the 4th parameter (meetings) has a meetings dataset and the 5th parameter is meetingType with a dataset of meetingType. So when the user selects a meeting, then the meetingType gets populated by that selection. Currently both dropdowns produce all results, which I don't want. I just want all results for meetings and then the meetingType gets populated by meeting.
The table it produces once the report is ran doesn't use those properties and there isn't a place to query anything. I can only use available values from each dataset and not use available values based on the selection of the 4th parameter.

I'm not really clear. do you need a parameter or do you just want to have the meeting type available as a value in your report output?
Fairly straightforward. You have two datasets, one for each parameter. You need to filter the second dataset based on the first parameter.
For example, I often create reports that ask for a range of values, let's say programs. Once the user has entered the beginning value, the ending value must be greater than or equal to the beginning value. So, on the ending value dataset I create a filter. In this case, the filter says that the field code (which is my program) must be between the starting parameter and the maximum value allowed:
You can make your filter as complex as needed - referring to the other parameter with a formula

You can also do this via separate datasets for each parameter.
Lets say you have two parameters #param1 and #param2
you want the values on #param2 to change based on #param1 selection.
You will have your main dataset (main_dataset) with a where clause something like this
where sometable.somecolumn = #param1
and sometable.someothercolumn = #param2
Now you create a dataset (param1_dataset) for #param1 which brings back all the values you require for this parameter
Now create another dataset (param2_dataset) form #param2 and add a where clause to it which restricts the returned list.. something like this..
where sometable.somecolumn = #param1
Now on your report parameters.. set the Available Values for each parameter (report parameter properties) to "Get Values from a query" and select the appropriate dataset and the value field and label field (returned by the dataset) for each parameter.
Now when you run your report, your parameter selection 2 should change based on what you selected for parameter selection 1

Related

Multi select parameter default set by previous multi select parameter

I have a report with several parameters, all in varying degrees depending on the value of its predecessors. I’m trying to convert from single selects to multi-selects. I’ve set the multiselect values for Report Type – see image – and would like to set the default value for the multiselect Jobs Type parameter. The logic would be: ‘If Jobs is not selected in Report Type, set ‘NA’ as default. If Jobs is selected, display the list of job types’. The job type dataset is used as the Available
Values list. I have a defaultJobType dataset with the following code:
IF 3 IN (#ReportType)
SELECT 0 as JobTypeId, 'N/A' as JobTypeDesc
Is there any way to accomplish this goal?
Create a DataSet to get "Default JobType" based on report type as per your requirement
like as you said IF 3 IN (#ReportType) SELECT 0 as JobTypeId, 'N/A' as JobTypeDesc
create a SP (stored procedure or query with parameter report type)
as we normally do for Cascading Parameters ...
once its done then set the default value of Job Type Parameter ,
1. select option "Get value from a query"
2. Choose DataSet which created to get Jobtype based on
3. set value field JobTypeId
you can also say that, there are two data set to populate Job Type one for populating drop down & another for select Default value...

How to hide parameter based on another parameter value in SSRS

I have 2 parameters param1 and param2. param1 has values true and false. My requirement is that if I select true in param1 then param2 should be hidden and if I select false in param1 then param2 should be visible. Can this be achieved in SSRS?
As per Nathan's comment I am adding Amar's comment here as answer/partial answer
Unfortunately, you cannot change a parameter's visibility during run time. Alternatively, you can control the second parameter's values based on the selected value of the first parameter.
Check this post - Hide parameter (dropdown control from the toolbar) in SSRS based on another Parameter
As Amar pointed out you cannot hide parameters dynamically, but what you can do is grey them out for single-value parameters, described here.
For multi-value parameters that won't work, because multi-value parameters are not allowed to be null.
But instead you can modify your DataSet and the default value for the parameter. To limit the user's choice list.
Let me give you an example:
Let's say you have 2 parameters that are cascaded. So you want to choose something from the first parameter and depending on what you choose in the first parameter you get a different result in second parameter. (Microsoft has a documentation about this)
Now we can use this cascading to set the values in the second parameter. So for instance if we choose the value 1 in the first parameter we want the second parameter act normal and show its data to choose from, but in any other case we want the second parameter to have limited data to choose from. And this what I'm going to show. You got a second parameter that looks like this:
In the Available Values we choose the DataSet with its values and labels for the second parameter. Which could look like this:
Now in the DataSet for the second parameter, here DataSet1, we need to specify when to show the limited data and when not:
So what we do is set one label All with the value -1 when the value of the first parameter is not 1 else the DataSet returns all the data from the table/function/stored procedure/ etc.
Lastly the second parameter shall have the default value -1 with the label All chosen when the first parameter is not 1. So back to the second parameter properties. For Default Values the value -1 needs to be specified:
So now the user only gets the preselected All in the list to choose from when the first parameter is not 1. Otherwise the full list will be provided. All that has to be done now is to declare what is done when the value of the second parameter is -1.

Unable to add SSRS Parameters/Filters

I have created a ssrs report which requires a drop down filter to select values.
The steps I have taken in report:
Created the Dataset
SELECT * FROM Voluntary_CCC_Split
Then applied where statement in dataset - where [WORK ORDER OPERATIONS TYPE] in (#WorkOrderOperationType)
The parameters now appears but when changing to available values and selecting dataset, value field and label field i get error below when generating report:
the report parameter has a default value or a valid value that depends on the report parameter. forward dependencies are not valid
I only have one parameter
Your parameter was configured to have its available values populated from a dataset that referenced the same parameter. Instead of this circular reference, create an additional dataset that simply returns the labels and values for the data you need, and use that to populate your parameters available values.

Using optional multi-value textbox as dataset filter

I have a report which returns list of product names and other product specs. This report currently has different search options. My users now also want to be able to search by product number by putting in multiple product numbers.
How can I add a filter by product number which is an optional multi-value textbox?
I have tried to add a multi-value textbox. The report doesn't seem to work when no values are entered. If I put one or more product number in the text box, it seems to work fine. Is there a way I can tell the report doesn't filter on the Null value parameters? Or any other idea to work with optional multi-value parameters?
Here is the setting for my multi-value textbox
Name = ProductNumber
Prompt = Product Number
Data Type = Text
Allow Blank Value (checked)
Allow Null value (not checked)
Allow Multiple Values (checked)
Here is the data set filter
Expression = [ProductNumber]
Operator = In
Value = [#ProductNumber]
Thanks
TL
I think you should trick the dataset filter by:
Expression should check to see if the parameter is blank and if so give expression a 1 else the field.
Value should do the same check and if parameter is blank set value to 1 else set it to the parameter.
But keep your operator.
Alternatively you could do this similarly in the SQL and with more flexibility and performance.
So as you've seen in your own testing, at least one value must be selected with multi-value parameters. You can't set Allow null value to true at design time and if you run a report without selecting any values it will throw an error message.
So you can't really have a report where users can run it with no values selected.
Taking a step back, what you're trying to achieve when ignoring the parameter is to include all Product Numbers by default. So why don't you set the parameter to have a default value of all Product Numbers selected? That way, users can just ignore and leave them all ticked if they don't want to filter by Product Numbers. Seems like a good workaround to me.
To do this, set the default value for the parameter using the same dataset that populates it:
All Product Numbers are now selected and users only need to take action if they want a subset of these returned.

Sending multiple values in ssrs parameter to subreport

Currently have three subreports, one main report.
Main report has two parameters - SELECTDATE and EMP_ID. Main report sends Order_Nbr to all subreports.
All subreports work perfectly when I only select 1 Employee and 1 date, but if I choose multiple values it blows up.
SQL has the column as an INT. I have both parameters in main report and subreport, SELECTDATE is set as Text with Multiple Values, and EMP_ID is set to Integer with Multiple Values. My queries has my date IN (#SELECTDATE) and emp_id IN (#EMP_ID).
It obviously sends the correct information to the subreports because it works, but I would like it to work with more values being passed. Love the current ability to check and uncheck employees and end of month dates, like it currently is set using the IN function in my query.
Make the Parameters on your sub report non-multivalue, remove any 'Available values' set.
Pass the multivalue parameter from you parent report as a string using the join method
=Join(Parameters!Emp_ID,",")
The EMP_ID parameter will be set to a comma delimited list, which is what a multivalue parameter sends to the query
I'm not sure how this works with text queries, but it works with stored procedures.
If the sub report is also used as a stand alone report you will need to add a new parameter to allow the user to send parameter values to #Emp_Id from a parameter the user can set
I guess you have not set the parameter in the sub report as Multi Select. If you have set the parameter in the sub report as multi select, then you could just send the parameter from the main report to the sub report as it is. See more at here
I used the following solution, which works in SSRS2016. This also works with text parameters.
Like suggested above, pass the parameter as a string to the subreport by JOINing the values.
Join(Parameters!EmpID, ",")
In your subreport, accept the parameter as text.
In the SQL of your subreport, use the string_split function of SQL 2016 to return a table of the values and simply join it to your main query. So basically if your parameter is named "EmpID_Multi" do
... JOIN (SELECT value FROM string_split ( #EmpID_Multi, ",")) mv ON mv.value= ...
Note: You might consider pulling the values into a temporary table for SQL optimization (sometimes the optimizer does funny things...).