Hi, I'm probably missing something really simply here, but can't see it. I
have a table that I'm tring to compute the following expression in rpt
designer.
=IIf(Sum(Fields!cancels.Value) >=1,
Sum(Fields!enrollments.Value)/Sum(Fields!cancels.Value),0)
it works when (Fields!cancels.Value) is >=1 but
when (Fields!cancels.Value) is not >=1 then it gives me a blank instead of
the 0.
when it rolls up to the group it gives me the #error
Any suggestions. Thanks, LisaLisa,
The problem is that SRS evaluates the entire expression. Even though
your syntax is correct, SRS still does the calculation and returns a
divide by zero error.
To avoid this, I suggest creating a custom code function to use instead
of doing the calculation in the expression. What I use is this:
Public Function DivideBy(ByVal exp1, ByVal exp2)
If exp2 = 0 Then
DivideBy = 0
Else
DivideBy = exp1 / exp2
End If
End Function
Your expression would then be:
=code.DivideBy(Sum(Fields!enrollments.Value),Sum(Fields!cancels.Value))
toolman|||thanks, got it
"toolman" wrote:
> Lisa,
> The problem is that SRS evaluates the entire expression. Even though
> your syntax is correct, SRS still does the calculation and returns a
> divide by zero error.
> To avoid this, I suggest creating a custom code function to use instead
> of doing the calculation in the expression. What I use is this:
> Public Function DivideBy(ByVal exp1, ByVal exp2)
> If exp2 = 0 Then
> DivideBy = 0
> Else
> DivideBy = exp1 / exp2
> End If
> End Function
> Your expression would then be:
> =code.DivideBy(Sum(Fields!enrollments.Value),Sum(Fields!cancels.Value))
> toolman
>|||Glad I could help
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment