July 24, 2014 at 8:55 am
Hi guys,
I have an Visual Studio 2005 SSRS Report. There are some report columns – january, february, … , december that must have Hidden=True or False. The parameter!Month is a multi value list, that can be checked 1 to 13 times (None, january, . . . , december).
(Property of january column:Hidden)=iif(Parameters!Month.Value(0)="None",True,iif(Parameters!Month.Value(1)="January",False,True))
Problem: Though “None” is checked in Value(0), the program tries to address Value(1) and gets an address overflow. How can I solve this in another way?
Regards
Ralf
July 25, 2014 at 3:53 am
Hi Ralf,
I think there is a misunderstanding here over how multivalue parameters work.
When your multivalue parameter is defined it does not allocate 13 elements where it stores whether the value is checked / unchecked.
What it does is return a string array containing the checked values. This means that you cannot always expect None to be at index 0, Jan to be at index 1 etc. It does however preserve the order the elements are listed in the parameter.
For example:
- if you select Jan, Apr, Dec they will be at indexes 0, 1, 2.
- if you select just Dec it will be at index 0.
- if you select None, Feb they will be at indexes 0, 1
What this means is you should not check position 1 contains Jan, you must check whether any position in the array contains Jan. (Granted, Jan is not going to be any position other then 0 or 1, but what about Dec? It could be in any one of 0 - 12)
** Caveat I don't have a SQL2005 instance so hopefully Filter existed way back then **
One way you could do this is the filter function which searches for values in strings in an array.
=Iif(Filter(Parameters!Month.Value,"Jan").Length > 0,True,False)
Filter searches the strings in an array for a value, in this case "Jan" and returns an array containing all the instances of that value, which is why we test the Length is greater then 0.
Another option with a unique list is to join the values into a string and search in the string;
=Instr(Join(Parameters!Month.Value,":"),"Jan") > 0
The key is to remember you are working with a string array.
July 25, 2014 at 4:16 am
Hi ??, many thanks. that was very enlightening:w00t::-) I'll gonna check it out. Regards Ralf
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply