Showing posts with label expression. Show all posts
Showing posts with label expression. Show all posts

Monday, March 12, 2012

pls help with expression question

I am converting reports from business objects to reporting services. In
business objects they have a variable called ERRORS created with the
expression
= If (<Value> InList (12 , 500 , 501 , 502 , 503 , 504 , 505 , 530 , 550))
Then 1 Else 0
<value> is a field returned from a stored procedure (so cant do this in the
sql) ... how can I create this field in reporting services? I know I can
create a calculated field and was thinking about IIF(Fields!Value.value
InList( .... ), 1, 0) but I cant use InList and I am not that good with VB
so looking for suggestions. Thanks!MJT, Here's some vb code that I think will work for that.
Public Function InKnownErrors(ByVal ErrorNumber As Int32)
Dim ReturnVal As Int32 = 0
Dim ErrorList() As Int32 = {12, 500, 501, 502, 503, 504, 505, 530,
550}
If Array.BinarySearch(ErrorList, ErrorNumber) >= 0 Then
ReturnVal = 1
End If
Return ReturnVal
End Function
Expression:
=Code.InKnownErrors(450)
"MJT" <MJT@.discussions.microsoft.com> wrote in message
news:6000B282-6685-4FC1-ABE7-B1F59EAE7544@.microsoft.com...
>I am converting reports from business objects to reporting services. In
> business objects they have a variable called ERRORS created with the
> expression
> = If (<Value> InList (12 , 500 , 501 , 502 , 503 , 504 , 505 , 530 ,
> 550))
> Then 1 Else 0
> <value> is a field returned from a stored procedure (so cant do this in
> the
> sql) ... how can I create this field in reporting services? I know I can
> create a calculated field and was thinking about IIF(Fields!Value.value
> InList( .... ), 1, 0) but I cant use InList and I am not that good with
> VB
> so looking for suggestions. Thanks!
>|||Thanks Steve for the code example. I wish I could come up with those that
quickly ... someday ...
I was able to get the InStr function to work this way in the textbox:
=IIF(Instr("12 , 500 , 501, 502, 503, 504, 505, 530, 550",
Fields!Value.Value ), 1, 0)
it seems to be working so far. I am checking out the accuracy of the result
now...
so I am grateful to have a backup plan ... thanks!
"Steve MunLeeuw" wrote:
> MJT, Here's some vb code that I think will work for that.
> Public Function InKnownErrors(ByVal ErrorNumber As Int32)
> Dim ReturnVal As Int32 = 0
> Dim ErrorList() As Int32 = {12, 500, 501, 502, 503, 504, 505, 530,
> 550}
> If Array.BinarySearch(ErrorList, ErrorNumber) >= 0 Then
> ReturnVal = 1
> End If
> Return ReturnVal
> End Function
> Expression:
> =Code.InKnownErrors(450)
>
> "MJT" <MJT@.discussions.microsoft.com> wrote in message
> news:6000B282-6685-4FC1-ABE7-B1F59EAE7544@.microsoft.com...
> >I am converting reports from business objects to reporting services. In
> > business objects they have a variable called ERRORS created with the
> > expression
> > = If (<Value> InList (12 , 500 , 501 , 502 , 503 , 504 , 505 , 530 ,
> > 550))
> > Then 1 Else 0
> >
> > <value> is a field returned from a stored procedure (so cant do this in
> > the
> > sql) ... how can I create this field in reporting services? I know I can
> > create a calculated field and was thinking about IIF(Fields!Value.value
> > InList( .... ), 1, 0) but I cant use InList and I am not that good with
> > VB
> > so looking for suggestions. Thanks!
> >
>
>

Saturday, February 25, 2012

Please help. How to set a Parameter in SSRS in runtime? Parameters!myParam.Value property is rea

You can set the default value of a reporting services parameter by any expression.

But with code I'm NOT allowed to do:

Parameters!myParam.Value = CDate("01.01.2007")

This is cause Value property is read-only.

So the question would be:

Are there any way I set a parameter value in runtime ?

Hope anyone can help...

Use VB.Net or C# code (Report -> Report Properties -> Code tab) to store the parameter in some shared variable. Use this variable to set and retrieve value whenever and wherever you need in the report by using the syntax Code.MySharedVar

Shyam

|||

Hi Shyam,

I have tried that also, but the problem is that the calendar control turn into a drop-down combo control when you apply either code or connect it to a dataset.

The parameter is a datetime type. As long as you add logic to the "default value" it showns the calendar control, if you add anything to "available values" the calendar disappears and a combo is shown. Any ida what I can do to keep it displaying the calendar control ?

|||

I guess you are raising a new issue now. I dont think your issue can be solved at the reporting services level.