SQLTeam.com | Weblogs | Forums

Highlighting text


#1

is there a way in SSRS to have the results of a query be highlighted based on the search criteria of a parameter?


#2

Yes. You can use an expression for the background color. In the expression you will be able to access the parameter and/or datasets as required.


#3

good suggestion, forgot about that.

but how would I make the argument?

i've tried many variations of this:

=IIf(Parameters!abcDesc.Value like "*Fields!ABC_Desc.Value", "Red", "Black")

basically I want to set just the text of one field(Fields!ABC_Desc.Value) if it equals the search criteria of a parameter(Parameters!abcDesc.Value)

thanks for the help!


#4

It should be something like this:
=iif(Parameters!abcDesc.Value=Fields!ABC_Desc.Value, "Red","Yellow")

See the screenshot below, which shows an example.


#5

gotcha, makes sense.

But what if I just want to do the text that matched.

Also, it may not be an exact match, for example if the parameter was 'world's'

The result would be

The world's richest people 2016


#6

SSRS expressions has a LIKE keyword. In the Expression Editor, you can see all the keywords and choices you have. The LIKE keyword example that they have is this:

=Fields!FirstName.Value Like "T*"

So in your case, you would do this:

=iif( Fields!ABC_Desc.Value LIKE Parameters!abcDesc.Value & "*", "Red","Yellow")

That does not answer your need to highlight only part of the text. I am not aware of that feature existing in SSRS. I don't know if they have added that in a newer version of SSRS. But if they haven't, you are stuck with using some clumsy workarounds such as constructing an HTML on your own like what is shown in this article.


#7

sounds good, thanks for your help and time.