Thursday, February 16, 2012

Checking for Null Values in a Table/Matrix Cell

What would be an equivalent expression for ISNULL(datafield, 0) for a table/matrix cell? I am using iif( Len().. to find out if there is something in the cell, and displaying zero in the cell if the length of cell item is 0, however am wondering if there is any better/elegant way of doing that?

=iif(fieldname = nothing, 0, fieldname)|||um, wouldn't that be =iif(fieldname = dbnull.value,0,fieldname) ?|||Actually, SSRS converts dbnull to an actual null in the report, so using:

iif(fields!fieldname.value = nothing , 0, fields!fieldname.value)

or

iif(IsNothing(fields!fieldname.value), 0, fields!fieldname.value)

seems to be the MSFT suggested way to trap for nulls.

iif(fields!fieldname.value = dbnull.value, 0, fields!fieldname.value) won't work. You might be able to get away with iif(fields!fieldname.value is system.dbnull.value, 0, fields!fieldname.value), but people have reported some issues with using System.DBNull and all the MSFT guys say to use "nothing".

No comments:

Post a Comment