Maybe @hkeric.wci came up with something much more precise, but a ton of the VB types I want to use says I can’t in SSRS.
So I don’t know if it’s cause I didnt’ make the report style and report data definition in the right order, but none of my filters work or are included in the code in SSRS rdl.
So I expanded on their report criteria logic and did it for the filters.
Here’s the thing, these filters can be multivalued… so you need to concatenate them to be used in an IN clause for an SSRS filter.
To concatenate a filter that you have you can use the code below.
Just replace “EmpID” in the code below with the name of your multivalued filter.
I don’t have the code worked out for the filter expression that you’ll have to use if it’s empty so that it returns everything.
Dim filterIndex = 0
Dim concatenatedEmpIDs As String = "" ' Initialize an empty string to store concatenated EmpIDs
While True
filterIndex = userCriteria.IndexOf("<RptCriteriaFilter>", filterIndex + 20)
If filterIndex < 0 Then
Exit While
End If
Dim filterName = GetElementValue(userCriteria, filterIndex + 20, "FilterName")
' Check if the filterName is "EmpID"
If String.Equals(filterName, "EmpID", StringComparison.OrdinalIgnoreCase) Then
Dim filterValuesStartIndex = userCriteria.IndexOf("<FilterValues>", filterIndex + 20)
Dim filterValuesEndIndex = userCriteria.IndexOf("</FilterValues>", filterValuesStartIndex)
If filterValuesStartIndex >= 0 AndAlso filterValuesEndIndex > filterValuesStartIndex Then
Dim filterValuesContent = userCriteria.Substring(filterValuesStartIndex, filterValuesEndIndex - filterValuesStartIndex)
' Extract and append each <FilterValue> value
Dim filterValueIndex = 0
While True
filterValueIndex = filterValuesContent.IndexOf("<FilterValue>", filterValueIndex)
If filterValueIndex < 0 Then
Exit While
End If
Dim filterValueEndIndex = filterValuesContent.IndexOf("</FilterValue>", filterValueIndex)
If filterValueEndIndex >= 0 Then
Dim filterValue = filterValuesContent.Substring(filterValueIndex + 13, filterValueEndIndex - filterValueIndex - 13)
' Append the filterValue to the concatenatedEmpIDs string, separating with commas
If concatenatedEmpIDs.Length > 0 Then
concatenatedEmpIDs &= ","
End If
concatenatedEmpIDs &= filterValue
filterValueIndex = filterValueEndIndex + 1
Else
Exit While
End If
End While
End If
End If
End While
' Now, concatenatedEmpIDs contains all the FilterValues separated by commas
values.Add("ConcatenatedEmpIDs", concatenatedEmpIDs)
You’d put that code in the custom code section of your SSRS report and then use the statement that @amaragni put above to get it back out. Using the code above you’d call the following code to get the concatenated empIDs.
=Code.GetCriteriaPromptValue(First(Fields!UserCriteria.Value, “RptParameter”),“ConcatenatedEmpIDs”)