Wednesday, March 7, 2012

Displaying a zero instead of NULL

I am using the expression below to display a zero (number 0) instead of NULL
=IIF(ISNOTHING(SUM(FIELDS!Dis.Value)),0, SUM(FIELDS!Dis.Value))
Whats wrong in this ? It gives me a blank but NO ERROR ..
ThanksYou can't sum a Null value - it doesn't result in a null, just an error. You
need to say:
=Sum(IIf(IsNothing(Fields!Dis.Value),0,Fields!Dis.Value)
--
Brian Welcker
Group Program Manager
Microsoft SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
"Asim" <Asim@.discussions.microsoft.com> wrote in message
news:13D84407-7151-44BE-A276-A3D557FFFC95@.microsoft.com...
>I am using the expression below to display a zero (number 0) instead of
>NULL
> =IIF(ISNOTHING(SUM(FIELDS!Dis.Value)),0, SUM(FIELDS!Dis.Value))
> Whats wrong in this ? It gives me a blank but NO ERROR ..
> Thanks
>|||You could also use the ISNULL function to make nulls 0
SELECT ISNULL(FeildName,0) From TABLE
"Asim" <Asim@.discussions.microsoft.com> wrote in message
news:13D84407-7151-44BE-A276-A3D557FFFC95@.microsoft.com...
> I am using the expression below to display a zero (number 0) instead of
NULL
> =IIF(ISNOTHING(SUM(FIELDS!Dis.Value)),0, SUM(FIELDS!Dis.Value))
> Whats wrong in this ? It gives me a blank but NO ERROR ..
> Thanks
>|||Correct Anwer is:
=IIF(ISNOTHING(Sum(Fields!Dis.Value)),0,(Sum(Fields!Dis.Value)))
"Asim" wrote:
> I am using the expression below to display a zero (number 0) instead of NULL
> =IIF(ISNOTHING(SUM(FIELDS!Dis.Value)),0, SUM(FIELDS!Dis.Value))
> Whats wrong in this ? It gives me a blank but NO ERROR ..
> Thanks
>

No comments:

Post a Comment