Conditional Formatting Question in SSRS report
In my SSRS report, I have two date columns (Requested Ship Date and Factory Commit Date). I would like to put the color in "red" if the request ship date column is greater than the Factory Commit date.
So I put the following expression in the color property. However, I got an error message, "Operator '>' is not defined for type Date & type Integer". How I can resolve it if I need to compare these two date
and would like to put "red" in cell in requested ship date column. In addition, if the factory commit date field is Null, there is no need to show the "red" color since the field is blank and cannot compare with the Requested Ship date. With this particular
case, I would like to keep "Black" color).
=IIF(Fields!Requested_Ship_date.Value > Fields!Factory_Commit_Date.Value,
"Red",
"Black")
Thanks,
Josephine
JT
October 6th, 2011 4:33pm
Please try the following expression:
=IIF(DateDiff("d", Fields!Requested_Ship_date.Value, Parameters
Fields!Factory_Commit_Date.Value) > 0, "RED", "BLACK")
Free Windows Admin Tool Kit Click here and download it now
October 6th, 2011 8:03pm
Hi Shahfaisal,
Thanks for your help.
I put this expresssion statement in "Requested_Ship_date' field in "Color properties. However, I looked the result, it seems to be not working the way I want.
For example:
In "Requested_Ship_Date" column, I had the date for Oct 24
In "Factory_Commit_Date" column, I had the date for Oct 31.
For this example, the Requested Ship Date is less than Factory Commit Date, I don't want to show in "Red" in the record. However, with this expression, somehow, the record turns "Red". I need to make the record show in "Red" when
the Requested Ship Date is greater than Factory Commit Date.
=IIF(DateDiff("d", Fields!Requested_Ship_date.Value, Fields!Factory_Commit_Date.Value) > 0, "RED", "BLACK")
Any idea how to fix it? Your input is greatly appreciated.
Thanks,
Josephine
JT
October 8th, 2011 11:59am
Try this:
=IIF(DateDiff("d", Fields!Requested_Ship_date.Value, Parameters Fields!Factory_Commit_Date.Value) > 0, "BLACK", "RED")
Free Windows Admin Tool Kit Click here and download it now
October 8th, 2011 12:09pm
Thanks! I noticed that if I use your new expression, if both dates are same (equal), the record will show 'red'. so I have added an equal sign into your statement.
However, I don't want Factory_Commit_Date column show "Red" when Factory_Commit Date is "NULL". Any idea to fix that. It will be perfect if you can fix this condition. Thanks a
lot!
Your expression:
=IIF(DateDiff("d", Fields!Requested_Ship_date.Value, Parameters Fields!Factory_Commit_Date.Value) > 0, "BLACK", "RED")
I have added an equal "=" sign into your expression so that it will not show red when Requested Ship Date and Factory Commit Date are equal
=IIF(DateDiff("d", Fields!Requested_Ship_date.Value, Parameters Fields!Factory_Commit_Date.Value) > = 0, "BLACK", "RED")
JT
October 8th, 2011 12:17pm
=IIF(IsNothing(Parameters Fields!Factory_Commit_Date.Value),
"BLACK", IIF(DateDiff("d", Fields!Requested_Ship_date.Value, Parameters Fields!Factory_Commit_Date.Value) > = 0, "BLACK", "RED"))
Free Windows Admin Tool Kit Click here and download it now
October 8th, 2011 12:22pm
=IIF(IsNothing(Parameters Fields!Factory_Commit_Date.Value),
"BLACK", IIF(DateDiff("d", Fields!Requested_Ship_date.Value, Parameters Fields!Factory_Commit_Date.Value) > = 0, "BLACK", "RED"))
October 8th, 2011 12:22pm
It works. Thank you.
BTW, I put this expression into "Requested_Ship_Date" field. It only show the field in "Red". How can I make the entire row turn red with the following condition? Thanks!
=IIF(IsNothing(Fields!Factory_Commit_Date.Value),
"BLACK", IIF(DateDiff("d",
Fields!Requested_Ship_date.Value, Fields!Factory_Commit_Date.Value) > = 0,
"BLACK",
"RED")) JT
Free Windows Admin Tool Kit Click here and download it now
October 8th, 2011 12:26pm
Click on the entire row(to do that you'll have to click on the left handle for that row) and go to the color properties and paste that expression.
October 8th, 2011 12:29pm
Thanks for your help. Much appreciated. Have a good day!JT
Free Windows Admin Tool Kit Click here and download it now
October 8th, 2011 12:33pm
You'll need to mark the right reply as answer....
October 8th, 2011 2:15pm