August 21, 2010 at 12:12 pm
I created the IIF function shown below, when I run the report it will work only on the fields where I have a due date, but if the due date is null I will see #error. Since the IIF was not working, I created a VB Custom Code function and I am getting the same results it will calculate a date only if the due date is null.
=Iif(IsNothing(Fields!DueDate.Value),dateadd("d",105,Fields!Accepted_Date.Value),dateadd("d",-45,Fields!DueDate.Value))
This is the function. What I am I doing wrong? Please help!
Function DecisionNeeded(myDueDate as datetime, myAcceptanceDate as datetime)
If isnothing(MyDueDate)
Return dateadd("d",105,myAcceptanceDate)
else
Return dateadd("d",-45,myDueDate)
end if
End Function
May 10, 2011 at 5:03 pm
sunnyplace (8/21/2010)
I created the IIF function shown below, when I run the report it will work only on the fields where I have a due date, but if the due date is null I will see #error. Since the IIF was not working, I created a VB Custom Code function and I am getting the same results it will calculate a date only if the due date is null.=Iif(IsNothing(Fields!DueDate.Value),dateadd("d",105,Fields!Accepted_Date.Value),dateadd("d",-45,Fields!DueDate.Value))
This is the function. What I am I doing wrong? Please help!
Function DecisionNeeded(myDueDate as datetime, myAcceptanceDate as datetime)
If isnothing(MyDueDate)
Return dateadd("d",105,myAcceptanceDate)
else
Return dateadd("d",-45,myDueDate)
end if
End Function
Essentially, IIF in SSRS executes both branches, then checks the IIF and returns whichever previously calculated value. So, it's attempting to do the DateAdd to the NULL value before actually checking! Dumb, dumb, dumb, but that's the way it is.
The simplest solution is to use a SWITCH instead of an IIF.
SWITCH( IsNothing(MyDueDate), dateadd("d",105,myAcceptanceDate),
1=1, dateadd("d",-45,myDueDate)
)
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply