Philip Kibaki's Blog

HTML Links Embedded within Text (SSRS 2008R2)

Overview

So, old news, from SSRS 2008 onwards, Reporting Services can render HTML Tags, although there are some limitations to the tags that can be used:

  • Hyperlink tag: <A href> 
  • Text formatting tags: <S>,<B>, <I>, <U>
  • List handling tags: <OL>, <LI>,<UL>
  • Font tag: <FONT>
  • Header, style and block tags: <SPAN>,<H{n}>,<LI>, <DIV>, <P>,  <HN>

I’ll be talking about using the hyperlink tags to drill through or link back to the same report within a lump of text return by a dataset.

Say your dataset returns some summary text that describes the data in the report, like “Sales for the Accessories Category amounted to £#,###.## putting it at around the 11th percentile” and you would like to drill through on the Keyword “Category” only and not the whole text.

So you want

  • Sales for the Accessories Category amounted to £#,###.## putting it at around the 11th percentile

Instead of

  • Sales for the Accessories Category amounted to £#,###.## putting it at around the 11th percentile

From a lump of text returned by a dataset.


Solution

We can handle this kind of request by generating the hyperlink to the report you would like to drill through in the dataset. This is as opposed to using textbox actions in the report. There are a number of advantages of handling this in the dataset

  • Turn on the HTML markup type in the place holder properties for the Summary_Text Field.

image

HTML Markup Type Setting

  • Now, you need to build the link to the report you are drilling to, this is best done in the report to keep it dynamic, therefore, deploying the report to a different server or folder won’t mean you have to change any code as you are going to use the global parameters available in SSRS.

    Create a hidden parameter that will hold the expression below. Alternatively, you can have this expression directly in the dataset parameter, just create a dataset parameter and in the value expression add this hyperlink expression.

    Pass this in to your dataset to complete it with the missing parameters; in this case Category Name is missing.

 

Blog2


HTML Link Expression

 Blog1

HTML Expression in Dataset Parameters

 


The incomplete generated link being passed to the dataset will look something like this:


image

  • In your dataset, complete your link with the missing parameter.

Blog3

Complete your HTML Expression and Create Hyperlink

It may be worth pointing out at this stage you can also add other HTML tags to edit the look of the text. You can add bolding to the text – as in my example above, or even have some conditional formatting to colour code the text. For example green for high percentiles etc.  (see the list of HTML tags available at the beginning of this post).

  • For this example, I am just linking back into the same report and passing in the category that has been clicked. You can of course link to a different report/Drill through.
    You end up with something like this


image

How it will look


You can find the example RDL here. I used the AdventureWorksDW2008R2 Database.

Leave a Comment

(required) 

(required) 

(optional)

(required)