April 24, 2009 at 4:53 am
Howdy all,
So I am new to the SSRS. Bought a book and started to go.
So far its been a walk in the park (with a lot of muggers).
Now I am stuck on this one problem. When I compute percents for my report, sometimes there are no sales for an area and I am getting NAN or #error or Infinity.
What I would like to do is show a 0 in that field instead.
The issue is that sometimes I am doing this on 4 fields (A_Rev_TY/B_Rev_TY) / (A_Rev_LY/B_Rev_LY)-1.
I don't really want to put 4 nested IIF's into the box, for my 56 boxs where I would need them.
Is there no way to say Don't show these errors or something I am missing?
Any Ideas?
Doug
April 24, 2009 at 6:07 am
in my case, i do all my calculations in the SQL, instead of in the report....
so my SQL would have one more field, that has this for the calculation:
(A_Rev_TY/B_Rev_TY) / (A_Rev_LY/B_Rev_LY)-1.
CASE
WHEN ISNULL(B_Rev_TY,0.0) = 0
THEN 0 --no need to calc the second part of the equation...zero divided by anything is still zero
ELSE
--another, inner case:
CASE
WHEN ISNULL(B_Rev_LY,0.0) = 0
THEN 0
ELSE (A_Rev_TY/B_Rev_TY) / (A_Rev_LY/B_Rev_LY)
END
END
Lowell
April 24, 2009 at 6:41 am
Thanks for that. That is a good idea and I will keep it in mind.
Not to go into too much detail, but my report gives 4 cuts of the same data. So its sorted by Month / Offices / Department&Owner / Product / Corporate Customer.
There is just no way to do all the calcs in the SQL (As you can't sum or average the percents)
So can I take it then there is no easy OnError Display 0.
🙁
Doug
April 24, 2009 at 9:06 am
Am not saying I *like* this (due to having to 'hook' the IsNaN function to the equation, doesn't appear to allow it to stand alone) but it works....
=Iif((Fields!field1.Value / Fields!field2.Value).IsNaN(Fields!field1.Value / Fields!field2.Value), 0, Fields!field1.Value / Fields!field2.Value)
so psuedo-code... if A / B is NaN then 0 else A / B
HTH,
Steve.
September 9, 2009 at 1:17 am
This works ! .. Thanks 🙂
October 28, 2009 at 2:10 pm
Very Helpful..... Thank you....:-)
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply