5

I have an expression in a table that checks if there was a return value.

If the query returns empty or null I want to set the value to 0.

=IIF(IsNothing(Fields!DndCount.Value),0,Fields!DndCount.Value)

But if the query returns empty IsNothing() does not work.

4
  • What's the datatype of DndCount? Is it a string? For a count field I would expect it to be an int, which doesn't have a concept of empty; it's either NULL or it isn't. Jul 7, 2013 at 10:17
  • the datatype is int, in some case the query returns zero lines, in this case how can I set the value to "0". Jul 7, 2013 at 10:30
  • Is this expression being used in a Detail row or in a Header/Footer row? Jul 7, 2013 at 11:40
  • You might find this helpful stackoverflow.com/questions/10319220/ssrs-no-data-in-report
    – Silagy
    Jul 7, 2013 at 20:20

5 Answers 5

3

I have tried this code and it worked for me.

IIF(Sum(Fields!DndCount.Value)Is Nothing, "0", Sum(Fields!DndCount.Value))
2
  • You sir, saved the day! Thank you. Jun 6, 2017 at 15:28
  • Great suggestion, but it still doesn't work on my stupid version of Report Builder. I hate MS's old garbage pre-Nadella. Jul 13, 2023 at 22:51
2

Alternative solution to avoid using expressions, change the cell format to #,##0 in properties. Easier then to pair it up with count or sum.

1

Try this:

=IIF(Fields!DndCount.Value=0 OR 
IsNothing(Fields!DndCount.Value)=0 OR
Fields!DndCount.Value="null",0,Fields!DndCount.Value)
0

Since IsNothing will return a True or False value you need to set your expression as:

=IIF(IsNothing(Field1) = True, 0, Field2)   

Hope it helps.

0

You can also try to use the IsMissing expression of the field,

like this:

=IIF(Fields!Accounting_Amount.IsMissing, 0, Fields!Accounting_Amount.Value)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.