Search code examples
reporting-servicesformulananinfinity

Removing NaN and Infinity from displaying in the reports


I tried using the logic given elsewhere on removing the NaN and infinity values but couldnt alter my formula based on that.

If somebody could please write me my formula including the NaN and infinity check.

I want Nan and infinity to appear as - in my report

My formula

= Fields!SOH1.Value / 
  ((1- ((Fields!retail3.Value-Fields!cost3.Value)/Fields!cost3.Value)) 
   * Fields!retail3.Value)

Thanks


Solution

  • Your formula will be returning NaN where SOH1 and either retail3 or cost3 is 0, while it will return infinity where SOH1 is not 0 and either retail3 or cost3 is 0.

    So the answer is to include a condition on all of these possibilities to display an alternative value instead. Assuming you want to display 0 instead of NaN or infinity, try:

    = iif(Fields!SOH1.Value=0 or Fields!retail3.Value=0 or Fields!cost3.Value=0,
          0,
          Fields!SOH1.Value / 
          ((1- ((Fields!retail3.Value-Fields!cost3.Value)/Fields!cost3.Value)) 
           * Fields!retail3.Value)
         )