简体   繁体   中英

SSRS - Adding “LIKE” filter criteria to report builder

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

你可以使用InStr函数

=IIF(InStr(Fields!MyFieldName.Value, "2451"),TRUE,FALSE)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM