Groups | Blog | Home
all groups > sql server reporting services > july 2004 >

sql server reporting services : Data filter question


Ibexx
7/22/2004 5:10:02 PM
I have created a report param of type string named BatchNumber. The default value is "All". However if the user wants to filter for a particular batch number they might change this param value to "1" or "2", etc.
This is my data filter:

Expression:
=iif
(
IsNumeric( Parameters!BatchNumber.Value ),
CInt(Parameters!BatchNumber.Value) = CInt(Fields!BatchNumber.Value),
True
)

Operator:
=

Value:
=True

When I run the report I get the following error only if ran with default value of "All":
Lev Semenets [MSFT]
7/22/2004 8:04:25 PM
The problem is this: The IIF function evaluates all of its arguments. So
CInt(Parameters!BatchNumber.Value) gets evaluated even if BatchNumber is
"All".

=iif
(
IsNumeric( Parameters!BatchNumber.Value ),
CInt (iif (IsNumeric (Parameters!BatchNumber.Value),
Parameters!BatchNumber.Value, 0)) = CInt(Fields!BatchNumber.Value),
True
)

By the way, why not to compare strings instead of numbers?
=iif
(
IsNumeric( Parameters!BatchNumber.Value ),
CStr(Parameters!BatchNumber.Value) = CStr(Fields!BatchNumber.Value),
True
)

--
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]

Ibexx
7/22/2004 9:57:03 PM
Worked like a charm - not sure why I didn't compare them as strings in the first place...

[quoted text, click to view]
AddThis Social Bookmark Button