Switch & IIF Conditional Formatting in SSRS 2008

conditionalformattingiifreporting-servicesswitch statement

I'm am having some trouble with conditional formatting in SSRS. I have tried Switch & IIF Statements (below). The report runs but is not returning colors as it I'm hoping it would. I'm trying to highlight dates which are <= today in red, and everything else will be black. Does it matter if this field is a date field? I've seeen other questions on here with the same issues but no resolutions. Was hoping today would be my lucky day to find an answer. Here is what I have tried and thank you in advance for any input.

        =Switch( Fields!Decision_Must_Be_Made.Value <= today(), "Red",  
         Fields!Decision_Must_Be_Made.Value > today(),  "Black")

        =IIF( Fields!Decision_Must_Be_Made.Value <=today(), "Red",  "Black")

Best Answer

Yes, it definitely matters if the field is a Date Time field. If it's a string, then you need to convert it to datetime first. How you do that will depend on the format of the string. But it will be much better if you can stick with a datetime field from the database. (I've seen where some will format a date to a string in the select of the sql query. Don't do that. Format as late as possible: in SSRS, at the text box level.)

If it is a dateTime, break up your formula to find out what's not working as expected and make it more visible, if only for debugging. Put this in the expression of a cell, for example:

=IIF( Fields!Decision_Must_Be_Made.Value <=today(), "Old",  "New")

Edited to add information on where the color formula should be added:

Sounds like you don't have the IIF specifying the color in the right place. There are a few different places you could specify this: it needs to be in the properties of either the textbox or the placeholder. The value for these things should simply be your date field (=Fields.Decision_Must_Be_Made.Value) but the font color needs to be specified separately. One place to do this is in the Text Box Properties dialog. In the font pane, you need to specify the font color. The Fx symbol indicates that you can specify a formula. Click this button for a place to enter your '=iif...' formula.

Text Box Properties font pane

Related Topic