I am using below expression in SSRS but is not giving expected result.
=IIf(Fields!Completed_Date.Value Is Nothing,
Nothing,
IIf(First(Fields!TIMEFORMAT.Value,"dsPreferences") = True,
Format(DateAdd("n",Parameters!UTCOffset.Value,Fields!Completed_Date.Value),"MM/dd/yyyy hh:mm:ss tt"),
Format(DateAdd("n",Parameters!UTCOffset.Value,Fields!Completed_Date.Value),"MM/dd/yyyy HH:mm:ss")
)
)
It has to check if Date is null.If it is null just leave field blank.If it is not null then it has to return value according to Time zone value that it is getting from another dataset.This expression works fine when there is non null date but it returns #error when there is Null date.
Try using this syntax:
=IIf(IsNothing(Fields!Completed_Date.Value), "", <yourFalsePart>)
This syntax probably doesn't solve your issue because Completed_Date is also used in the false part. IIf operator will always evaluate both expressions before deciding which one to use: so if Completed_Date is Nothing it will broke your expression anyway.
Try using a Custom Function as explained here: SSRS expression giving error with iif condition
Related
Hi guys I have a simple IFF expression
=IIF(Fields!MYCOLUMN.Value = true, "Yes", "No")
which is working fine, except other rows that have a blank or NULL in it's place are returning "No".
Is there a way to adapt my expression so that it ignores Null values? I have tried incorporating ISNOTHING but having trouble getting the syntax right.
IFF, IIF, or IF? If this is in the SQL query/stored proc and not the report itself, the answer below just changes to a SQL CASE statement.
Use a switch statement to define what you want displayed in the third case.
=Switch(
Fields!MYCOLUMN.Value = true,"Yes",
Fields!MYCOLUMN.Value = false,"No",
true,"")
Hi all, I have an expression in SSRS that calculates the Due date from the Last Fit Test. The data is correct if the Last Fit Test has a date. However, if the Last Fit Test is Null or blank, it gives an error "########" (it supposes to return empty or blank). How can I fix that expression?
=IIF(IsNothing(Fields!LastFitTest.Value) = True,"",DateAdd(DateInterval.Year,1,Fields!LastFitTest.Value))
Try this ...
=IIF(
IsNothing(Fields!LastFitTest.Value),
"",
DateAdd(DateInterval.Year,1,IIF(IsNothing(Fields!LastFitTest.Value), '1900-01-01', Fields!LastFitTest.Value))
)
The problem was the IIF always evaluates both the true and false condition so when you had no value in LastFitTest the false side could not evaluate even though it would never be used.
All we have done here is made the date that get processed in the DateDiff function always return a valid date. The 1st Jan 1900 means nothing, you can put any date you like in there as it will never be used in the final result.
The only other change was to remove the = True. IsNothing returns True/False so you don't have to explicitly say =True.
I'm having trouble determining if an SSRS 2016 text report parameter is null or blank. Here is my parameter's properties:
And this is the expression I'm using to display it. If it's non-null or non-blank I want to display it as a formatted date, otherwise "N/A".
=IIF((Parameters!EndDateTime.Value = "") OR IsNothing(Parameters!EndDateTime.Value), "N/A", Format(CDate(Parameters!EndDateTime.Value),"dd MMM yyyy HH:mm:ss"))
But when I run the report I get "#Error" if the value is blank:
What am I doing wrong here?
Thanks.
This is because the IIF() function evaluates always both arguments. Here you will find more information about it: IIF Evaluation
You either go with the IsDate() function to check if it is a date before you convert it or you can use a Switch() statement.
The field is taken from the table and is the source of data for the textbox, in which I want to apply conditional formatting. Almost always it is NULL. The expression for the conditional formatting:
Not IsNull ([duedate])
Always returns true, I do not understand why. Field [duedate] belongs to the parent form.
I think you need to check the length also along with IsNull like
Len(Field) = 0
My datasource is XML (sharepoint list). I basically want to show the date formatted if the value in the field is a date and if not then show "NA". For some reason, even when the data is a a string it is still trying to convert it to a date somewhere. Here is my code..
=IIF
(
ISDATE(replace(First(Fields!ows_Manufacturing_Date.Value, "DataSet1"),"datetime;#","")),
formatdatetime(replace(First(Fields!ows_Manufacturing_Date.Value, "DataSet1"),"datetime;#",""),2),
replace(First(Fields!ows_Manufacturing_Date.Value, "DataSet1"),"string;#","")
)
The problem is that the IIF statement in SSRS doesn't short circuit, it always evaluates both conditions, so even if the field is not a date, it still tries to do the formatdatetime function.
(See this: SSRS iif function question)
Instead of the IIF function, try using the SWITCH function instead:
=SWITCH(First(Fields!ows_Manufacturing_Date.Value, "DataSet1")="string;#NA",
"NA",
First(Fields!ows_Manufacturing_Date.Value, "DataSet1")<>"string;#NA",
formatdatetime(replace(First(Fields!ows_Manufacturing_Date.Value, "DataSet1"),"datetime;#",""),2))