Sunday, July 21, 2024

Document Maps in SSRS

 Document maps in SSRS (SQL Server Reporting Services) provide an easy way for users to navigate through large and complex reports by creating a clickable table of contents. This is particularly useful for reports with multiple sections or groupings, allowing users to jump directly to the desired part of the report.

Step-by-Step Guide to Creating a Document Map

Let's create a document map for a report that displays sales data grouped by region and product category.

1. Create the Report

  1. Open SQL Server Data Tools (SSDT) or Report Builder:

    • Open your preferred tool where you create and edit SSRS reports.
  2. Create a New Report:

    • Create a new report or open an existing report where you want to add a document map.
  3. Add a Data Source:

    • Add a data source that connects to your database. For example, connect to an SQL Server database that contains your sales data.
  4. Add a Dataset:

    • Add a dataset that retrieves the data you want to display in your report. For example, use the following SQL query to fetch sales data:
    sql

    SELECT Region, ProductCategory, ProductName, SalesAmount FROM SalesTable

2. Add a Table to the Report

  1. Insert a Table:

    • From the toolbox, drag a Table onto the report design surface.
  2. Bind Data to the Table:

    • Drag the fields (Region, ProductCategory, ProductName, SalesAmount) from the dataset to the respective columns in the table.

3. Group Data by Region and Product Category

  1. Add a Parent Group for Region:

    • Right-click on the table row and select "Add Group" -> "Parent Group."
    • In the "Group by" field, select Region.
    • Check "Add group header" if needed.
    • Click "OK" to create the group.
  2. Add a Child Group for Product Category:

    • Right-click on the detail row and select "Add Group" -> "Child Group."
    • In the "Group by" field, select ProductCategory.
    • Check "Add group header" if needed.
    • Click "OK" to create the group.

4. Add Document Map Labels

  1. Region Group:

    • Right-click on the text box that displays the Region field in the group header.
    • Select "Text Box Properties."
    • Go to the "Document Map" tab.
    • In the "Label" field, enter or select the Region field to use it as the document map label.
    • Click "OK" to apply the changes.
  2. Product Category Group:

    • Right-click on the text box that displays the ProductCategory field in the group header.
    • Select "Text Box Properties."
    • Go to the "Document Map" tab.
    • In the "Label" field, enter or select the ProductCategory field to use it as the document map label.
    • Click "OK" to apply the changes.

5. Preview and Test the Report

  1. Preview the Report:

    • Click on the "Preview" tab to view the report in action.
  2. Check the Document Map:

    • In the preview, you should see a pane labeled "Document Map" on the left side (or it may be a collapsible tab depending on your version).
    • The document map should list the regions and, when expanded, the product categories under each region.
    • Clicking on any item in the document map should navigate to the corresponding section of the report.

Additional Tips

  • Custom Labels: You can use expressions to create custom document map labels if the field values are not descriptive enough.
  • Hierarchical Navigation: Document maps can support multiple levels of hierarchy, making them ideal for complex reports with nested groups.
  • Visibility: Ensure the document map pane is visible in the report viewer settings to make use of this feature.

Full Example Summary

Here’s a summary of what you’ve done:

  1. Created a new report and added a data source and dataset.
  2. Inserted a table and bound it to the dataset fields.
  3. Grouped the data by region and product category.
  4. Added document map labels to the region and product category group headers.
  5. Previewed and tested the report to ensure the document map works as expected.

By following these steps, you can create a document map in SSRS that enhances the navigability of your reports, making it easier for users to locate and access specific sections of the report.

No comments:

Post a Comment