Removing NaN
Within my Matrix the percentage calculation sometimes returns a NaN value, how do i remove this... This is my calculation i am using =sum(IIF(Fields!Students.Value = 0, 0, 1))/iif(len(count(Fields!ID.Value)) = 0, 0, count(Fields!ID.Value))
October 7th, 2010 1:25pm

Sorr what is NaN? Just three charactersBest Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
Free Windows Admin Tool Kit Click here and download it now
October 7th, 2010 1:32pm

Uri, NaN means 'Not a Number'. Hi Sam, I'm sorry, I couldn't understand what your expression is doing. From what I understand, the error that you are getting (NaN) is because the value of your denominator is 0. It is the 'Divide By Zero' error actually. In your expression, you have the following in your denominator - iif(len(count(Fields!ID.Value)) = 0, 0, count(Fields!ID.Value)) You are checking if the length of your count(Fields!ID.Value) field is 0 or not. In case it is 0, the True part of IIF returns 0. This could be a reson for the error. Another observation - even if the count(Fields!ID.Value) returns 0, the length would still be non-zero (because the length of 0 is 1, I hope you understood). So, because the length is non-zero, the False part of the IIF would be evaluated. The False part returns count(Fields!ID.Value) which is 0. So again the 'Divide By Zero' error (or NaN in your case). I think you should have the following expression as your calculation - =IIF(count(Fields!ID.Value) <> 0,sum(IIF(Fields!Students.Value = 0, 0, 1))/count(Fields!ID.Value),nothing) Please note that I have assumed here that if the count(Fields!ID.Value) is 0, the calculation wouldn't happen hence the 'nothing' is the False part of the above IIF expression. Hope this helps. Cheers, ShalinShalin P. Kapadia
October 7th, 2010 1:58pm

Very Good Explanation Shalin Adding to Shalin's point , there may be null values also coming in the Fields!Students.Value or Fields!ID.Value . So consider using IIF(isnothing(Fields!Students.Value ),0,Fields!Students.Value ) Below is the link for the similar thread http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/fb0f9f16-e142-4a9c-8e9b-fcc84a7f6a0e
Free Windows Admin Tool Kit Click here and download it now
October 7th, 2010 2:35pm

Thanks, Sorna. Sam, as mentioned by Sorna above, you also need to handle the Null value scenario in your expression. I missed that point in my earlier reply. Thanks for pointing that out, Sorna. Cheers, ShalinShalin P. Kapadia
October 7th, 2010 2:39pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics