Search code examples
c#model-view-controllerrdlcreportviewer

RDLC Report Viewer expression returning #ERROR with IIF expression


Can somebody tell me what is wrong? This is my RDLC expression:

=IIF(Last(Fields!totalHour.Value) <> "" OR "--:--" , "Total Hours  " & Last(Fields!totalHour.Value), " ")

And it is returning #ERROR

I don't know if it is happening because it returns a null value, but if it is what should i do?

And if i set to always show the value it works:

=Last(Fields!totalHour.Value)

I also tried this and it keeps sending the same error:

=IIF(Last(Fields!totalHour.Value) <> "" OR "--:--" OR "00:00" , "Total Hours  " & Last(Fields!totalHour.Value), " ")

This is the information that is passing to my dataset : "00:00"


Solution

  • This will fix the issue you are comparing string, not int. Your expression will work if it is an int but fail if the value is a string so you need to write it separately like below.

    =IIF(Last(Fields!totalHour.Value) <> "" OR Last(Fields!totalHour.Value) <> "--:--" , "Total Hours  " & Last(Fields!totalHour.Value), " ")