0

I have read the posts about divide by zero, and using functions to overcome it, which I usually do with normal reports.

What I can't find is how to handle the divide by zero issue on calculated fields. You can't use a function because of aggregation (which calculated fields does not allow), so I do not know how to get round it.

I could write some more SQL just for this pie chart I am doing, but it is part of an existing report and ideally I want to use what is already there.

Does anybody know how to handle divide by zero issues for calculated fields?

Example: =Fields!Other.Value/Fields!Total.Value*100

Thanks,

Kevin.

Wingmiester
  • 15
  • 1
  • 3
  • 10
  • Why do you need to apply this in a calculated field? You can just do this in the report expression to get around the SSRS short-circuit issue, as per http://stackoverflow.com/questions/1204179/does-the-iif-function-compute-both-paths-in-ssrs-or-is-it-short-circuited – Ian Preston Jan 30 '14 at 17:44
  • You were right, I had over complicated it. There is no real need to handle divide by zero in the calculated field, I can do it (in this case) with the series properties of my pie chart. It turns out I don't even need to be dividing as the pie chart will do the percentages for me just based on a value. Thanks. – Wingmiester Jan 31 '14 at 09:13

1 Answers1

0

It's been a while since I used reporting services, but can't you validate the Total value before doing the division? Something like this:

=iif(Fields!Total.Value>0,Fields!Other.Value/Fields!Total.Value*100,0)

spacesam
  • 1
  • 1
  • 2