简体   繁体   中英

Filter Multivalue Parameter on Dataset

So I have a multiple value parameter than contains 3 options. >250K, <250K, >2M. I also have a table that consists of multiple columns. 图片1 图片2 . Because the parameter is a multivalue, i am having difficulties filtering the dataset.

I need to filter the dataset by checking, (if > 250K is selected, filter the dataset accordingly), (if < 250K is selected, filter the dataset accordingly) and (if > 2M is selected, filter the dataset accordingly).

I was told to use a join and split on the parameter within the (>250K condition, then do a contains to see if it contains any of the parameter values) but I am not as advanced in my knowledge of coding to be able to do that.

Any Suggestion? Thanks in Advance

I previously tried the method below but then i came to realise that it wont work because the parameter is a multi value.

在此处输入图片说明

If you want to use multi-parameters, In the dataset, you can read parameter value using JOIN .

Example:

If you want to read multiple values for @MyParamter in a dataset given in the following example:

Dataset Parameters 在此处输入图片说明

you need to use =JOIN(Parameters!myMultiParamter.Value,",") as an expression to read all selected values in CSV form.

Expression 在此处输入图片说明

Now the @ParameterValues param has all selected values as comma separated values and you can use them in your dataset code as per design requirements.

Note: It's not necessary to use a comma but u can use anything you want to separate values.

I know its been a while since you raised this, you were on the right track but all you should need to do is add a filter to the Tablix on the field you will be filtering, use the 'in' operator and in the Value type [@Yourparametername] the square brackets and case sensitivity are important. Also ensure the expression type is correct, in your case it looks like you are using Integer. The image should help. 表矩阵

Your sql query where should look like

Where
(
(0 IN (@Parameter) AND ValueColumn<250000)
OR
(1 IN (@Parameter) AND ValueColumn>=250000)
OR
(2 IN (@Parameter) AND ValueColumn>=2000000)
)

One parameter

在此处输入图片说明

Two parameters

在此处输入图片说明

All parameters

在此处输入图片说明

Once you return the value you can also use charindex or patindex* and look for where the value in your where clause is a pattern where the index number is > 0 . For instance if the returned string from SSRS is '01,02,03' and then your where clause has something like this right(field, 2) which would result in value '03' . you change your where clause to be where patindex('%' + right(field, 2) + '%', @returnedstring) > 0 which will give you results. The keeps you from having to parse apart the @returnedstring parameter in your sql code.

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