Friday, August 12, 2011

SSRS - How to add a Document Map to your reports


One of the most common things I do during taking interviews is to give real life scenarios and assess the person on how he tackles the situation. Most of the times, what I really look for is how he goes forward in solving the problem – the approach and the way of thinking rather than the answer itself. Another thing that I look for is whether he tries to put some extra effort to implement the solution (especially the reporting part) in an aesthetic and user-friendly way. Most of the candidates would know the answer to some simple question like how to add data labels to their charts but they stutter when I ask what are smart labels or how can we prevent the cluttering of data labels. I would easily give brownie points to someone who details his solution with some extra attention to details. It must be my frequent rendezvous with creating big reports that make me extra fond of document maps in SSRS and an essential part of my SSRS interview questions.
It is hard to imagine going through a big book that has no table of contents. But many users and developers have no problem at all in designing big reports without any navigational aid (although at some point of their wretched life, the users are going to curse the person who developed those reports), even though Microsoft has provided this feature. Document Map is a navigational feature in SSRS that, when implemented, allows the user to navigate through the document and its hierarchies. With this feature, you can add a panel to the left of the reports where you can have the list of “contents” of the report. What makes it more special is that on clicking the “content” in the list, you will be directly taken to the page where the content is present. Cool feature, huh?
Requirement
Suppose you already have a matrix or a table with some groupings as shown below
Matrix - Subcategory grouping
Suppose the number of subcategories are very large and spans into multiple pages and the requirement is such that each user has to specifically search for a set of subcategories at a particular time of the day. It would make his life a lot easier if there was a document map listing the subcategories on clicking which he would be directly taken to the clicked subcategory
Solution
1) Go to the design mode of the report and click on the group properties of subcategory.
Subcategory group properties
2) Go to the advanced tab of the properties and set the Document map as the field Subcategory (you can select the appropriate field name from the drop-down).
Advanced group properties
3) Save the report, deploy it and then preview it .
Report DM Preview
Already you can see the panel at the left hand side which contains the list of subcategories. To hide/unhide this panel, you can click on the icon that has been highlighted in red in the above image. Notice that the “Document Map” text highlighted in blue is the report name.
4) Now you can click on any of the subcategories, say Handlebars and you would be taken to the page where the clicked subcategory is.
On clicking Handlebars 
5) (a) You can also make document map labels for each of your report item. For eg, if you have 2 tables, you can click on the table and press F4 to see the properties.
Table document map label
5) (b) You can give the required name in the DocumentMapLabel property as shown above and then see the required result when you preview the report.
DM Tables
6) Now that you have seen the toggle symbol, you would have already guessed that it is possible to create hierarchies also in the document map label, for e.g., Subcategory—>Product. For that, all you need to do is to enable Document Map property for the Product group also.
Subcategory - Product Hierarchy DM
Note

“ Document Map is mostly for
HTML rendering. Other renderers render differently.

o PDF: Uses Bookmarks.
o Excel: Uses named worksheet with hierarchical links. Report sections appear in other sheets.
o Word document also has a document map like the table of contents.
o Tiff, CSV, and XML ignore this setting.
o Recursive data is related to the idea of self joins where the relationship between parent and child is represented by fields in the dataset. “
So there ends the part 3 of my interview series. In my next blog, I would be taking a momentary break from my interview question series and presenting a very interesting application of Document Maps, wait for it :)