SSRS parameters based on previous parameter - reporting-services

In my report I have a parameter which allows the user to choose one or multi-options.
Driver 1,
Driver 2,
Driver 3
I have another parameter that would only be valid if they chose Driver 3 from the previous parameter.
AAA,
BBB,
CCC
So maybe the user would choose Driver 1 and Driver 3 and then choose BBB. How can I have the report provide all the data for Driver 1 and only BBB for Driver 3?

Are the lists of parameter values coming from the database? If so you can use the result of the first parameter to filter the query for the second.
For example. If we wanted to be able to select from a list of geographical regions and then from there choose from a list of countries that exist in those regions we could do something like this.
Create a new dataset called say dsRegions and get a list of regions from the database with something like
SELECT RegionID, RegionName From dbo.Regions
Create a new parameter #regions and set it to be multi-value and set the available values to be from a dataset. select dsRegions and use the ID column as the value and name column as the label.
Create another dataset say dsCountries but this time the query will look something like this.
SELECT CountryID, CountryName FROM dbo.Countries WHERE RegionID IN (#regions)
Note: It is important to use IN (#regions) and not = #regions or the query will fail when more than one region is selected.
Create a new parameter #countries, set it up as we did with the previous parameter but this time pointing it at dsCountries
This way, anytime the user selects a new region or regions, the #regions parameter is updated, then the countries list will be re-queried and populated.
Finally, the #countries parameter would be passed to the main dataset for the report.
Assuming your 1st and 2nd parameters have a similar relationship then you should be able to adapt this generic example easily.

Related

How to store multiple value in one available value in SSRS reporting

Currently i wanted to search multiple value in one available value which configured in SSRS.
Now user required to click one by one to filter their report as per below.
enter image description here
However they requested to group red highlighted into 'CCB KV' and green highlighted into 'CCB N' therefore instead user click one by one and they can directly click 'CCB KV' to filter those red highlight.
Currently we expect to use the available value option below to create 'CCB KV' and store those red highlighted and not require any script change. However it seems like available option only allow single value to store instead of multiple value and the query is using where clause as 'ce.branch_code in (#branchCode)' to obtain the result.
enter image description here
Seek you advise whether available value able to store multiple value.
The easiest way would be to add a table to your database containing the relationship between the parameter value and the values you actually want to search for.
For example you could create a dataset with the following in your dataset query.
CREATE TABLE myLookupTable(AreaName varchar(50), LocationName varchar(50))
INSERT INTO myLookupTable VALUES
('Area ABC', 'Tower A'),
('Area ABC', 'Tower B'),
('Area XYZ', 'Tower X'),
('Area XYZ', 'Tower Y')
For you parameter list you could then create a dataset in your report something like
SELECT DISTINCT AreaName from myLookupTable ORDER BY AreaName
Set the available values of your parameter to point to this dataset.
Then in you main dataset, just add a join in to this new table
SELECT a.* FROM myMainTable a
JOIN myLookupTable b on a.LocationName = b.LocationName
WHERE b.AreaName IN (#myParameterName)

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

SSRS Cascading Parameters

At the run time user will select the country for which the report
should run.
Next we will show all states of the selected country on parameter
screen.
Next we will show all cities of selected state on parameter screen.
How can we achieve this?
I'm not really sure, but here's what i think:
Create Your Parameter
Set your parameter value based on others parameter value, and send it to parameter data set to retrieve its data. (maybe you can use expression to do this)
Hope it would help :)
Regards,
David Tan
I could achieve it.
I created first a dataset for my report with Country, State and City fields.
After this, first parameter is country, user will select the country at run time.
After this, I have added another dataset2 to select all the states based on first parameter. I created another parameter to show multiple states. For this parameter I provided 'available values' as the second dataset viz., dataset2. This dataset2 was accepting parameter country and populating the states at the run time. I provided 'default values' as well as dataset2.
This same way I implemented the 'city' parameter. It worked.
Thank you!
Yes we can achieve that.
Let say you have two dropdownlist as a parameters, A and B.
You give A list of data from dataset
for B, you use dataset too to retrieve the data, but when you create dataset for B add filter and set parameter A as its value.
Add Filter for paramater B and set A as its value
Hopefully it would help :)
Thankyou.
Create three different parameters as country,state and city in your dataset and add one line to the dataset query as where country = #country and state = #state and city = #city.
Now coming back to your question, If your sql has duplicate countries,state or cities it wil return duplicate values so create three different datasets for three parameters.Like "Select Distinct country from Person.country" and state is dependent on country so write query for state as "Select Distinct state from Person.Country where Country = #country" and same goes for city.
Hope this answers the question

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

Report Builder 3.0 Forward Dependency Report Parameter

I have a report that I am working on that will do the following:
Return results based first on the community selected by the user.
Filter to find alike addresses within the community, based on the number of square feet at each address.
Set the end date (a column within the data table) to a user defined parameter for use in a WHERE at the end of the query.
The relevant information is stored in the following places:
Community: ub_subdivision.descr
Address: ub_serv_loc_addr.location_addr
SqFt: arp_ops.dbo.vw_ub_serv_loc_classifications.SqFt
I have setup the query with 3 parameters:
#Community
#Months
#Address
When the user is running the report, the following should happen (in this order):
The community parameter should populate the values stored in ub_subdivision.descr and allow the user to select the community they want from that list.
The address parameter should populate the values within the selected community from step 1, and allow the user to select the address they want from that list.
Based on the selected address, the query should store the value of the SqFt related to this address and use that in the WHERE statement as follows: WHERE (arp_ops.dbo.vw_ub_serv_loc_classifications.SqFt = #Address)
The months parameter should allow for user input to define how many months of data they want. This parameter is called in the query in the WHERE statement: WHERE (ub_bill_run.def_end_dt > DATEADD(m, -#Months, GETDATE())).
If I save the dataset and create a "table report" in Report Builder 3.0 it does the job of recognizing the various parameters and loading them into the Parameters folder and into the Datasets' parameters.
The problem I have is that I am not able to change the parameter properties to display Available Values and select "get from a query". If I go this route, and try to run the query I get an error that I am using "forward dependencies".
I need the #Address parameter to display the address field as the label, but store the sqft field as the value. This is the way I know how to do this and, unfortunately, it doesn't seem to work.
I would appreciate any insight anyone may have.
Thanks!
John
There is one way to solve this make sure the order should be in the order of
#Community
#Months
#Address
change order to:
#Community
#Address
#Months
just delete existing #month and again add it manually and save it.
i hope it will work for you.
You cannot have parameters based on your main data set.
The forward dependency error is caused because your data set is to be filtered by your parameter, yet it is depending on the same data set to find its' set of values. This is a sort of paradox.
When using queries to define the set of values for your parameters, make sure you create a new data set for each parameter.
Next, make sure the parameters are listed in the order you want them to run. Within the data sets for your parameters, you may use where clauses to make them dependent on one another in the order that they run.
In this example:
Parameter data set for Community:
SELECT DISTINCT ub_subdivision.descr
FROM [YOUR JOINED TABLES]
Parameter data set for addresses:
SELECT DISTINCT ub_serv_loc_addr.location_addr
FROM [YOUR JOINED TABLES]
WHERE ub_subdivision.descr IN (#Community)
Parameter data set for SqFt:
SELECT DISTINCT SqFt
FROM [YOUR JOINED TABLES]
WHERE ub_subdivision.descr IN (#Community)
AND ub_serv_loc_addr.location_addr IN (#Address)
You should also make a month data set for your #month parameter, however it is not dependent on the other parameters so I will leave that to you.
Hope this helps!