Multi select parameter default set by previous multi select parameter - reporting-services

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...

Related

SSRS Optional parameter with empty field

I need to run the report, without selecting anything, with parameter field blank, and be able to view all the data.
the problem is that it necessarily asks me to enter a value (all or multi values).
Who can help me?
If you make sure that you do the following...
Set the parameter to "Allow blank value" and/or "Allow null value" depending on what datatype it is.
Set the default value to Blank (="") if applicable
If you have a list of available values set, make sure the default value is included.
The following example uses sample data from sample database and contains just a list of company names and their ID's.
The main dataset query filters the data based on 2 parameters (one is text the other id numeric to show different scenarios)
This is the dataset query
SELECT CustomerID, CompanyName
FROM [AdventureWorksLT2019].[SalesLT].[Customer2]
WHERE CompanyName LIKE '%' + #pSearch + '%'
and CustomerID > ISNULL(#pID, 0)
ORDER by CompanyName
The report design looks like this with 2 parameters defined
The first parameter is text and has "Allow blanks values" checked, the Default value is set to an expression =""
The second parameter is an integer, This time we have set "Allow null value" on but we have not set a default value.
Note: Neither parameter has any available values set...
When the report is run I get the following results without pressing anything.
Only if I manually set any of the parameters do I need to press View Report, but when the report first runs, there is no need to click anything.
If the above does not help, then show how the parameter(s) are setup up, what types they are, what the available values are and what the default values are.

Populate a parameter dropdown based off another parameter

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

How do I combine data types in a SSRS Parameter?

Background -- I’m trying to create a report in SSRS using Report Builder 3.0 that contains multiple parameters. The request is when the report is opened, display all rows of data. The end user can then select one or more of the parameters to reduce the results displayed. I can get it to work using something like the following.
Data sets for Parameters where available values are from a query,(dataset type is text)
For fields that are numbers:
SELECT 0 'FACG' UNION ALL SELECT DISTINCT STR(ACG) FROM STG_CSI_SA_CONFIRM
For columns containing text:
SELECT 'Any' 'FunderName' Union All Select DISTINCT NAME FROM STG_CSI_SA_CONFIRM
In the dataset for the report I have this:
WHERE ('Any' IN (#FrName) or Fname.name in (#FrName)) AND ( 'Any' IN (#FACG) OR FLIST.FACG IN (#FACG))
The results are two Parameter boxes, one says 0, one says Any, and the report runs when first opened. End user can then select one or more numbers from FACG or one or more names from FRName.
My question is, how can I adjust the first parameter to show ‘Any’ instead of a zero as the default value? All the values returned would be integers of 7 digits long. When I simply change the 0 to Any I get an error message about converting data types. If I use STR() I can get a list out of SQL server I get a list as I expect. ( Any, 1234567, 1234568 etc.) But I cant get the list to work in SSRS.
Thanks
R
Two way to do this.
1. Make sure the dataset that provides values for your parameters has two columns, an ID column that you will use to actually do the filtering/joins in your dataset and the other column is the label which will be visible to the user. Something like
ID Label
'Any' 0
'1234567' 1234567
'1234568' 1234568
If you main data dataset is a query (not a Stored proc) then you can simply have a parameter dataset as above but without the 'Any' row. Then set you available value to the parameter dataset and the default values to the same parameter dataset. By default all parameters will then be selected.
In your main data dataset the query would be along the lines of
SELECT * FROM myTable WHERE myColumn IN (#myParameterName)
SSRS will turn the selected values from the parameter into a list of comma separated values and inject them into the query for you.

Report Manager - "Select all" as default for some linked reports

I would like to know if it is possible in report manager to give a specific linked report a "Select all" as default for a parameter.
Here is where i want to set the parameter to select all:
in Report Builder or Visual Studio:
create the parameter query like:
select null as value, '<ALL>' as label
union all
select distinct value, label from xxxxxxxx
this will return the values with specific row on the top.
now in your dataset where clause you can set the following and it will return all or whatever is selected:
XXXXX=CASE WHEN #parameter IS NULL THEN XXXXX ELSE #parameter END
set the XXXXX to the column that provides the parameter info, make sure you set the parameter to accept null values.
Then all you have to do in SSRS is pass null into that parameter
set the default value as 'NULL' in the parameter
There is probably a different, easier way but it works for me.
In order to do something like this, you will have to provide a list of possible values for the parameter. This can be done either by using the Specify values in the Available Values, or the Get values from a query option, in the parameter properties.
This is done in the report designer, or Report Builder. It cannot be done reliably via Report Manager (like in your screen capture).
Once you have that in place, make sure the default values for the parameter are set to all available values.

optional multi-value dropdowns/parameters in report

I have an SSRS report with 3 dropdowns.
1st drop down is for doctorDepartment and is multi-value
2nd is for insurancePolicy and is multi-value
3rd is a list of doctors and is single value only
The 3rd drop down get's it data from a dataset with the query below.
The two parameters, #specialityId and #insurancePolicy are controlled by the 1st two drop downs respectively(doctorDepartment & insurancePolicy).
The problem is, I need the user to be able to selectively choose a value from either drop down or both.
But the way it works now, is that a value from both is REQUIRED in order to display the data in the 3rd drop down...meaning the 3rd drop down is only populuated with data until the user chooses a value from both the 1st and 2nd drop down.
Is there a way to tell SSRS that the user only needs to select a value from 1 or the other or both but not require both?
I tried allowing null values for the 1st two parameters but SSRS will not allow you to set that option of the parameter allows multi-values.
Thanks!
SELECT ml.doctorID, doctorDisplayName
FROM doctorList ml
INNER JOIN doctorDepartment mc ON ml.doctorID = mc.doctorID
WHERE (mc.specialityId IN (#specialityId)
OR ml.insurancePolicy IN (#insurancePolicy))
ORDER BY doctorDisplayName
You can do this with default values:
Add an extra label/value pair to the first two parameter lists; this value can be a space ' ', -1, a word like 'Default', etc.
Set default values for both to these new values
Update your WHERE clause to allow one or more selected parameters:
WHERE mc.specialityId IN (#specialityId) AND 'Default' IN (#insurancePolicy) --first param selected
OR 'Default' IN (#specialityId) AND ml.insurancePolicy IN (#insurancePolicy) --second param selected
OR mc.specialityId IN (#specialityId) AND ml.insurancePolicy IN (#insurancePolicy) --both selected