Using the IN operator to filter in reporting services

JsonStatham picture JsonStatham · Nov 7, 2013 · Viewed 88k times · Source

Can anyone advise what the syntax should be when using the IN operator within a table filter. I have tried the below but the snytax is wrong:

enter image description here

Answer

Jordan H picture Jordan H · Dec 10, 2013

I had some troubles with this one as well. Microsofts own documentation states a simple comma delimited list of values in the Value box should work. This is confusing because IT DOESN'T. At least it didn't for me and I am using SSRS 2012 with Visual Studio 2010.

It turns out that when you are using the IN operator, SSRS is expecting an array of values. There are a number of ways you can make this work for the filter. The following examples are meant to be typed out in the expression editor.

The first way (also the way explained in the blog linked below) is to simply type your comma delimited list in a string value and then use the split function on it.

=split("2B,2C",",")

Or you can derive your list from a multi-value parameter. The multi-value parameter is already an array so all you have to do is reference it via the parameter expression as seen below.

=Parameters!MultiValueParam.Value

I found out this information via the following blog. http://sqlblogcasts.com/blogs/simons/archive/2007/11/20/RS-Howto--Use-the-IN-operator-in-a-filter-expression.aspx