简体   繁体   English

SSRS:在参数表达式中使用NOT LIKE

[英]SSRS: Use NOT LIKE in parameter expression

I have a report that uses 3 parameters: 我有一个使用3个参数的报告:

  • @startDate @开始日期
  • @endDate @结束日期
  • @Brand @牌

The @startDate and @endDate parameters are working as expected. @startDate和@endDate参数按预期方式工作。 @Brand is displayed as a dropdown menu with two options: B and P @Brand显示为带有两个选项的下拉菜单:B和P

When the user selects B the results returned must match the filter: LIKE ”%.%” When the user selects P the results returned must match the filter: NOT LIKE “%.%” 当用户选择B时,返回的结果必须与过滤器匹配: LIKE ”%.%”当用户选择P时,返回的结果必须与过滤器匹配: NOT LIKE “%.%”

I am not sure how to make this filter work for P. 我不确定如何使此过滤器适用于P。

I was searching for an answer for this exact problem and I could not find. 我正在寻找这个确切问题的答案,但找不到。 I am posting here though because I have discovered how to do it. 我在这里发帖是因为我发现了如何做。 Btw * is wildcard in SSRS 顺便说一句*是SSRS中的通配符

Your expression for a normal LIKE statement 您对普通LIKE语句的表达

=iif(variable LIKE "*.*", True, False)

Your NOT LIKE expression 您的不喜欢表达

=iif(NOT(variable LIKE "*.*"), False, True))

The easiest (and least elegant) option is just to have an IF statement in your SQL: 最简单(最不优雅)的选择是在SQL中包含IF语句:

IF @Brand 'B' THEN
   SELECT * FROM Table WHERE Filter LIKE '%.%'
ELSE
   SELECT * FROM Table WHERE Filter NOT LIKE '%.%'

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

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