简体   繁体   中英

How to filter a column using multi value parameter list in SSRS

I am new to SSRS. What I thought should be very simple took me 1 day and I am not able to fix it. All I need is the following

Select * from table1 where len(username) <= 6
Select * from table1 where len(username) >= 7

I want to display a drop menu with two options Short Username and Long Username. When a username click the short username the first query result is showed and when the user click Long username the second query result is showed.

What I did so far is I added a parameter list with two values ie Short parameter list = 6 and Long parameter list = 7. I then added two filters. In the first the expression= len(NameColumn.value) operator= <= value = @parameter. In the second the expression= len(NameColumn.value) operator= >= value = @parameter. Can you please what can I do to achieve it.

I think it may work better to do the filtering in the query rather then use the SSRS filters. Try this query.

select * from table1 where (@Parameter = 0 and len(username) <= 6) or (@Parameter = 1 and len(username) >= 7)

And your parameter could be setup like this.

在此处输入图片说明

You can do a similar FILTER in the dataset that @energ1ser mentioned.

You would have a Parameter where the user selects either Long or Short. You might use different values for it.

For the expression, you would use:

=IIF( (Parameters!YourParameter.Value = "Short" and LEN(FIELDS!USERNAME.VALUE) <= 6) 
   OR (Parameters!YourParameter.Value = "Long"  and LEN(FIELDS!USERNAME.VALUE) >= 7), 1, 0)

For the type, use Integer , and Operator = and Value 1 .

This expression calculates each row as 0 or 1 and then filters it for the 1 's.

To display ALL records, add another OR for when All is selected for the Parameter.

=IIF( (Parameters!YourParameter.Value = "Short" and LEN(FIELDS!USERNAME.VALUE) <= 6) 
   OR (Parameters!YourParameter.Value = "Long"  and LEN(FIELDS!USERNAME.VALUE) >= 7) 
   OR (Parameters!YourParameter.Value = "All"), 1, 0)

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