4

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.

http://connect.microsoft.com/SQLServer/feedback/details/202792/ssrs-adding-like-filter-criteria-to-report-builder

What do you guys suggest?

Thanks
Ravi Gupta

Darren
  • 68,902
  • 24
  • 138
  • 144
TechnicalSmile
  • 1,387
  • 5
  • 16
  • 30

7 Answers7

7

You could use the InStr function

=IIF(InStr(Fields!MyFieldName.Value, "2451"),TRUE,FALSE)
Darren
  • 68,902
  • 24
  • 138
  • 144
  • Thanks darren for prompt reply, what I need is "=IIF(InStr(Fields!MyFieldName.Value, "2451*"),TRUE,FALSE)" and I get error saying invalid character when I write this. – TechnicalSmile Apr 30 '12 at 11:52
  • Below worked for me IF(FIND(MyFieldName, "24") = 1, TRUE, FALSE) Got this idea from your answer. Thanks. I'll add this as answer to my own question, but can do so only after 8 hours. – TechnicalSmile Apr 30 '12 at 12:21
  • Seems to me that this doesn't really answer the question since it doesn't handle wildcards. It's nice that the OP was able to move on with his project, but it doesn't help future users who are looking for a way to use wildcards in an SSRS filter. – Tab Alleman Jan 19 '15 at 20:38
  • @TabAlleman this answer has been accepted and helped the OP, which was my aim. If you have a better solution then feel free to post it. – Darren Jan 19 '15 at 21:34
4

In SSRS we can't use Like. Instead of which you can use Contains.

IIF((MyFieldName).ToString().Contains("RequiredString"),"True","False)
Robert
  • 5,278
  • 43
  • 65
  • 115
3

In the report builder in Visual studio there is a Like and it works. Use a * as wildcard in your search string

Gertjan
  • 519
  • 4
  • 5
1

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

TechnicalSmile
  • 1,387
  • 5
  • 16
  • 30
0

The Report Builder does not support the LIKE operator. You must use CONTAINS;

Diego
  • 34,802
  • 21
  • 91
  • 134
0

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.

Joey C
  • 59
  • 2
  • 12
0

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 ='')

openball
  • 21
  • 4