SSRS - Adding “LIKE” filter criteria to report builder
-
04-06-2021 - |
Question
I want to add a LIKE filters with wildcards in SSRS report builder. I tried this using contains clause present in filter data section of report builder. I tried both '*' and '%', but of them failed.
I tried MyFieldName contains 2451 - this succeds MyFieldName contains 24* - this fails MyFieldName contains 24% - this fails
From below link I feel that this is an old problem with no solution till yet.
What do you guys suggest?
Thanks
Ravi Gupta
Solution
You could use the InStr
function
=IIF(InStr(Fields!MyFieldName.Value, "2451"),TRUE,FALSE)
OTHER TIPS
In SSRS we can't use Like
. Instead of which you can use Contains
.
IIF((MyFieldName).ToString().Contains("RequiredString"),"True","False)
Answering my own question, Below function worked for me:
IF(FIND(MyFieldName, "24") = 1, TRUE, FALSE)
This is just a partial answer as this will work for cases like (blabla*), but its not for cases like (bla*bla, blabla*). So anyone having a better idea is most welcome.
Got idea to do this from Darren's comment above.
Thanks
Ravi Gupta
In the report builder in Visual studio there is a Like and it works. Use a * as wildcard in your search string
The Report Builder does not support the LIKE
operator. You must use CONTAINS
;
This is pretty late to the party, but I worked out a solution for parameter filters for my dataset.
Adding a filter to my dataset with
Expression:
=IIF(InStr(Fields!AccountName.Value, Parameters!paramAccountName.Value) OR Parameters!paramAccountName.Value = "*", TRUE, FALSE)
Type
Boolean
Operator
=
Value
true
The parameter are defaulted to "*" so the report looks like it grabs everything by default.
I just came across this old thread and I'm curious why you can't use the like keyword, since I've always used it. Did you try something like this? Where (AccountName like '%' + @paramAccountName + '%' or @paramAccountName ='')