SSRS “OR” Filter Logic to filter from “=” and “IN” Operators

后端 未结 2 1278
悲&欢浪女
悲&欢浪女 2021-01-16 04:08

I\'m working on a report where it needs to filter data from either of the two Built-in Fields. so I\'m using the \"FilterExpression\" to query my requirement based on the be

相关标签:
2条回答
  • 2021-01-16 04:41

    I recently came across the same need do a DATASET FILTER with OR criteria using an IN operator and EQUALS (=) operator.

    The answer by [Hannover Fist] includes the expression code with INSTR() function. In my scenario I had to filter against Number Datatype values. DEVELOPERS BE FOREWARNED... the INSTR() expression is only reliable with TEXT Datatype values. See the screenshot provided below.

    I don't know why Microsoft doesn't just provide the option to change the assumed [AND] criteria to a configurable [AND/OR] criteria to be selected by the report developer. A configuration filter criteria would be so much simpler than the BOOLEAN FILTER EXPRESSION work-around option.


    SSRS-DatasetFilter_(OR Condition-IN Filter).png

    0 讨论(0)
  • 2021-01-16 04:51

    I would use the InStr function to search for the State field in the list.

    Your expression would look like:

    =IIF(Fields!Country.Value = "United States" Orelse InStr("Washington,Minnesota,Tennessee, Oregon", Fields!State.Value) > 0, 1, 0)
    

    I usually use 1 and 0 for the filter values - SSRS doesn't always like the TRUE FALSE returned from expressions like 1 = 1 when comparing them as a boolean.

    Microsoft: Instr-function

    0 讨论(0)
提交回复
热议问题