July 27, 2006 at 3:55 am
Hi All
I am a new user of reporting services and i am trying to calculate %.
i am doing this simply with the help of expression with this formula
=Fields!Margin.Value/Fields!Sales.Value
It is working well but sometime my Sale value is zero in that case it gives me "#Error " entry on my report.
How i can get rid of it?
Many Thanks.
July 27, 2006 at 6:27 am
Hey,
Try this
=IIF(Fields!Sales.Value0,Fields!Margin.Value)/ IIF(Max(Fields!Sales.Value)=0,1,Max(Fields!Sales.Value))," ")
Regards
Raj Deep.A
July 27, 2006 at 6:40 am
Many Thanks for reply
I tried that and got this error
Argument not specified for falsepart of public funcation IIF(Expression as boolean,True Part As Object,Falsepart as Object) as Object.
Regard's
Vandy
July 31, 2006 at 12:43 am
Hi,
IIF(Fields!Sales.Value>0,
Fields!Margin.Value)/ IIF(Max(Fields!Sales.Value),
0)
Try with this.
Thanks & Regards,
Kumar KP.
Thanks & Regards,
9989069383
Katakam.
July 31, 2006 at 8:00 am
Hi Kumar KP
Many Thanks for response but having same error msg which i posted in the last post...........
Kind Regard's
August 1, 2006 at 3:59 am
Try:
=IIF(Fields!Sales.Value<>0, Fields!Margin.Value/Fields!Sales.Value ,"")
August 1, 2006 at 5:34 am
An iff statement will not work when checking for a zero value before division. .NET evaluates the true/false portion of the statement first and as such, will immediately throw an error. To get around this, use a custom function in your code using a try-catch.
August 2, 2006 at 4:46 pm
Further to David's response:
1. On the Report Menu (in Layout veiw) choose Report Properties
2. Select the Code Tab and create a function, e.g.:
Function DivideMe (ByVal quotient As Double, ByVal divisor As Double) As Double
dim returnValue as Double = 0
If (divisor <> 0) Then
returnValue = quotient / divisor
End If
return returnValue
End Function
3. Back in the report, in the expression editor type
=Code.GetMargin(Fields!Margin.Value, Fields!Sales.Value)
August 3, 2006 at 6:33 am
Excellent .................
Many Thanks TomT, #Error is removed from my report now it's showing 0% instead of #error tag.
Once again thanks for solving my problem and for giving me new tip.......
Kind Regard's
August 4, 2006 at 8:22 am
You're welcome
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply