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
Related
I am building a summary report which looks at users that are marked in a database as having a common trait i.e return all users by name in the last 5 years whose contract contains an end date.
This generates a figure e.g. [250]
I drill through on that figure to give a list report of names, first name and surname.
I have ordered the list A-Z
I would like to add a row of 26 letters at the top of the report and have each letter return only the names with the corresponding starting letter.
Would this need to be a further drill through or is it possible to refresh the existing list based on a user-driven selection?
Just add a custom parameter to your report. Right click on Parameters and Add Parameter.
(and so on...). Default value should be All then.
Then simply add the following filter to your tablix:
'Expression:
=Switch(Parameters!YourParameterName.Value = "All", True, Parameters!YourParameterName = Left(Fields!YourNameField.Value, 1), True)
If you are just using SSRS as it comes, then you can't refresh report content without running the report again, so you would either
re-organise your current report.
need another drill through report.
Depending on your layout you could group the data by the first letter and then have an collapsible row group to show/hide that group of names. To do this simply add a parent row group, set the value, group value and sort value all to =LEFT(Fields!myNameField.Value). Next set the visibility of the details row group to hidden and set the toggle visibility property to point to the cell that contains the letter from the parent group you just created.
If you have too much data to make this efficient the you might have to go down the additional subreport route.
To make life a bit easier, and to save you having to create 26 links and parameter values, I would do the following...
Create a table that stores the list of letters
Add a matrix to your report, that has a column group grouped on the letter value from this table. This will act as your 'filter bar'
Set action on the matrix cell to "go to report", point to the final drill thru report and pass the [myLetterColumn] value as the parameter.
There's no need to set available parameters assuming this sub-report will be hidden and only called from the parent report.
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
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...
On my report I have two parameters.
One is for the selection of an order number from a list (dropdown list) and the other is for typing an order number. The idea is to have the end-user either select the order number or type it, not both...
Is there a way I could empty the textbox when a list item was selected and vice versa, i.e. selecting an empty value from the dropdown list once an order number has been typed? I thought about using code but it would be impossible to determine which of the two parameters to use once the "view report" button has been pressed.
Any other approaches to this situation are very welcome.
Thanks in advance for any replies.
Define the parameters
Let's assume the first parameter that allows the user to enter the order number is called typed_value and the second parameter that allows the user to select an item from the list is called list_value.
Prevent list from being used if value is typed in
Add the following to the where clause of the query that populates the list_value
WHERE #typed_value IS NULL
This will prevent any records from being returned when the typed_value is not NULL, blocking the customer from selecting an order from the list if they have already typed in an order.
Update list_value with typed_value
The above code will only remove the list items, but to get the list to populate with the typed value add this union to the query that populates the list_value
UNION SELECT #typed_value WHERE #typed_value IS NOT NULL
If the user leaves the typed_value NULL then they can select any value from the list_value. If the user types in a value, the list will automatically be replaced with their typed_value.
Which value to use?
You can power your report filter off of the list_value and ignore the typed_value because if the user enters any value in typed_value, the list_value will be updated to the typed_value.
Smooth out the UX
Make sure the parameter typed_value allows null value. It may be a good idea to set the default value of typed_value to NULL so that the user can see the list values when the report first loads.
Also setting the default value of the list_value to #typed_value will automatically set the list_value to whatever value a customer types in.
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.