SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Replacing NaN with 0 or blank
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

lee_van_cleef
Starting Member

2 Posts

Posted - 03/18/2013 :  11:05:59  Show Profile  Reply with Quote
Hello,

I have the following:

=(Sum( IIF( Fields!YEAR.value = 2013, Fields!Number.Value, nothing)) - Sum( IIF( Fields!YEAR.value = 2012, Fields!Number.Value, nothing)) ) / Sum( IIF( Fields!YEAR.value = 2013, Fields!Number.Value, nothing))

I'm trying to find the difference over those years however the problem is when there are no values it returns NaN. Or if there are values for 2012 and none for 2013 it returns error or infinity.

How do I change this to show as either 0 or preferably be blank

Thanks
Lee

Edited by - lee_van_cleef on 03/19/2013 11:35:05

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 03/18/2013 :  12:57:13  Show Profile  Reply with Quote
use IsNan() function to check for NaN values. its used as Double.Nan() in SSRS

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 03/19/2013 :  10:23:59  Show Profile  Reply with Quote
can you show your current used query?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000