bmsqldev
bmsqldev

Reputation: 2735

Customer colour in IIF expression -SSRS

We have a column in our SSRS report which shows the date value based on expression.

We used below expression.

="Actual Max Date: " + (IIF(String.IsNullOrEmpty(First(Fields!ActualMaxDate.Value, "dataset1")),"N/A",First(Fields!ActualMaxDate.Value, "dataset2")))

the logic is as below,

IF the date is NULL then "N/A" is displayed , else actual date is displayed. Here my requirement is to show the string "N/A" in red colour. How to achieve it in SSRS?

Upvotes: 2

Views: 1785

Answers (2)

Hannover Fist
Hannover Fist

Reputation: 10870

You would need to use the same condition that determines the N/A to determine the color:

=IIF(String.IsNullOrEmpty(First(Fields!ActualMaxDate.Value, "dataset1")), "Red", "DimGray")

Place the expression in the Color property of the text box - it's on the FILL tab if using the popup property box.

To color only part of the text in the textbox, you would need to use HTML formatting in the expression.

="<b>Actual Max Date: </b><font color='" 
& IIF(String.IsNullOrEmpty(First(Fields!ActualMaxDate.Value, "dataset1")), "Red", "Black") & "'>" 
& IIF(String.IsNullOrEmpty(First(Fields!ActualMaxDate.Value, "dataset1")), "N/A", First(Fields!ActualMaxDate.Value, "DataSet1"))
& "</font>"

Make sure you set the Markup Type of the Placeholder Property to HTML.

Upvotes: 1

Marco Bong
Marco Bong

Reputation: 690

Right click the textbox => Properties => BackgroundColor =>

Fill in your expression like

=IIF("N/A"="N/A","Red","Blue")

Upvotes: 1

Related Questions