Sol Web Solutions Blog
Sol Web Solutions Blog is aimed to help, inform, educate and enable our site visitors.
Multiselect dropdown parameter for a SSRS SharePoint List report
1. First create the data source in your Datasets folder.
In my case, my dataset is called dsStatusDDL because I'm pulling a status field from a SharePoint list.First create the data source in your Datasets folder.
TWO THINGS to also keep in mind which may help you for this dsStatusDDL dataset:
- Some values are NULL (this will cause the multiselect dropdown parameter to be blank and appear to have no values)
- I thought the values would be either null or "Approved", but it looks like I have a row containing a value that has an extra space on the end (I found this out by creating an expression and using the len() on the end of the field...and b/c the multiselect dropdown list appeared to have duplicate values of:
- Blank
- Approved
- Approved
I couldn't just do an applied filter where the Status field was not null, b/c then all my "BLANK" rows wouldn't come in.
How to fix that little gem?
- Right click on dsStatusDDL and select "Add Calculated Field"
- Field Name was "Status_Cleaned"
- Created and expression of >> =iif(isnothing(Fields!Status.Value), "BLANK", ltrim(rtrim(Fields!Status.Value)))
- Using "BLANK" to make is very obvious to the user the status field was in fact blank or w/o value.
- Using ltrim(rtrim( got rid of that one pesky space on the end of that one record (and maybe more in the future)
By now, the Dataset dsStatusDDL is ready to go.
Next, put this function to grab the distinct values from the above Dataset in Report >> Report Properties >> Code:
Public Shared Function RemoveDuplicates(parameter As Parameter) As String()
Dim items As Object() = parameter.Value
System.Array.Sort(items)
Dim k As Integer = 0
For i As Integer = 0 To items.Length - 1
If i > 0 AndAlso items(i).Equals(items(i - 1)) Then
Continue For
End If
items(k) = items(i)
k += 1
Next
Dim unique As [String]() = New [String](k - 1) {}
System.Array.Copy(items, 0, unique, 0, k)
Return unique
End Function
2. Create Your First Hidden Parameter to pull from the above Dataset:
- Create a parameter called DistinctStatusHidden
- Make sure you select "Allow Multiple values"
- Make sure you select "Hidden" for the visibility
- On Available Values, select "Get values from a query"
- Make sure the Dataset is dsStatusDDL, Value Field is Status_Cleaned, and Label field is "Status_Cleaned"
- Default Values should also be from Dataset dsStatusDDL and Value field is Status_Cleaned
3. Now, create another parameter called StatusPull:
- Make sure you select "Allow Multiple values"
- Make sure you select "Visible" for the visibility
- For Available Values, select "Specify values"
- For Label >> put in the expression =Code.RemoveDuplicates(Parameters!DistinctStatusHidden)
- For Value >> put in the expression =Code.RemoveDuplicates(Parameters!DistinctStatusHidden)
- For Default values, select "Specify values"
- For Value >> put in the expression =Code.RemoveDuplicates(Parameters!DistinctStatusHidden)
4. Finally, for the actual filtering tie to bring back all or selective status records.
I have no grouping in my report, but just a single "Row Groups" line of (table1_Details_Group):
- Right click this and select "Group Properties"
- Go to Filters and click Add
- For the Expression >> I added the following (isnothing works with the Nulls, and the ltrim(rtrim gets rid of my spaces):
=iif(isnothing(Fields!Change_Status.Value), "BLANK", ltrim(rtrim(Fields!Change_Status.Value))) - Operator is "In"
- Value is my @StatusPull parameter
...and viola...you're done...and I hope this helped save you some time and effort!
Thanks!
Thank you, your article immediately helped me fix Default Values issue in my multiselect drop down. In my case if Default Values contain values that are not found on the drop down, nothing will get selected.