简体   繁体   English

SSRS - 向报告生成器添加“LIKE”过滤条件

[英]SSRS - Adding “LIKE” filter criteria to report builder

I want to add a LIKE filters with wildcards in SSRS report builder.我想在 SSRS 报告生成器中添加带有通配符的 LIKE 过滤器。 I tried this using contains clause present in filter data section of report builder.我尝试使用报告生成器的过滤器数据部分中存在的 contains 子句。 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我试过 MyFieldName 包含 2451 - 这成功 MyFieldName 包含 24* - 这失败 MyFieldName 包含 24% - 这失败

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 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 .在 SSRS 中,我们不能使用Like Instead of which you can use Contains .您可以使用Contains代替它。

IIF((MyFieldName).ToString().Contains("RequiredString"),"True","False)

Answering my own question, Below function worked for me:回答我自己的问题,以下功能对我有用:

IF(FIND(MyFieldName, "24") = 1, TRUE, FALSE) 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*).这只是部分答案,因为这适用于 (blabla*) 之类的情况,但不适用于 (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.在 Visual Studio 的报表生成器中有一个 Like 并且它可以工作。 Use a * as wildcard in your search string在搜索字符串中使用 * 作为通配符

The Report Builder does not support the LIKE operator.报表生成器不支持LIKE运算符。 You must use CONTAINS ;您必须使用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.我刚刚遇到这个旧线程,我很好奇为什么不能使用 like 关键字,因为我一直在使用它。 Did you try something like this?你有没有尝试过这样的事情? Where (AccountName like '%' + @paramAccountName + '%' or @paramAccountName ='')哪里(AccountName 像 '%' + @paramAccountName + '%' 或 @paramAccountName ='')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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