Reputation: 496
I have a field in my SSRS report, that contains a string of numbers delimited with commas (from a coalesce select in SQL). It looks like 12, 91, 160, 171, 223. I would like to change the text color of only ONE specific value (160 for example) in the field, IF the value is also in another field of the report.
I already have this for an expression for the Font of the field properties.
=iif(Fields!Store_Number.Value.ToString().Contains (Fields!DMHomeStore.Value)= True,"Red","Black")
This changes the text color of the entire field, not just that ONE value in the string.
Basically, if DMHomeStore
= 160, and Store_Number
has 160 in it's string, then make only 160 Red in the Store_Number string.
Upvotes: 4
Views: 25927
Reputation: 100
SSRS will not render all html tags, for example styling will get dropped from span tags. Heres a good reference http://dinesql.blogspot.com/2010/05/reporting-services-2008-showing-html.html
Upvotes: 1
Reputation: 49413
This can certainly be done and isn't difficult to do.
That's the first step. Now, all we need to do is set up an expression that will find the string in question and then replace it with HTML code to make it red.
=Replace(Fields!Store_Number.Value.ToString(),Fields!DMHomeStore.Value," `<span style='color:red'>` " & Fields!DMHomeStore.Value & "`</span>`")
Run your report and only the string in question will be red and all other text in the cell will be black. If the string in question isn't found then all other text will be black.
Upvotes: 7