Interactive Sort (Report Builder and SSRS)


Applies To: SQL Server 2016

You can add interactive sort buttons to enable a user to toggle between ascending and descending order for rows in a table or for rows and columns in a matrix. The most common use of interactive sort is to add a sort button to every column header. The user can then choose which column to sort by.

However, you can add an interactive sort button to any text box, not just column headers. For example, for a text box in a row outside a row group, you can specify a sort for the parent group rows or columns, for child group rows or columns, or for the detail rows or columns. You can also combine fields into a single group expression, and then sort by multiple fields.

System_CAPS_ICON_note.jpg Note

You can create and modify paginated report definition (.rdl) files in Report Builder and in Report Designer in SQL Server Data Tools. Each authoring environment provides different ways to create, open, and save reports and related items.

When you add an interactive sort, you must specify the following items:

  • What to sort: Rows or columns?

  • What to sort by: A field that is displayed in a table column? A field that is not displayed?

  • What context to sort in: For example, you can sort on rows associated with row groups; columns associated with column groups; detail rows; child groups within a parent group; or parent and child group together.

  • Which text box to add the sort button to: In the column header or in the group row header?

  • Whether to synchronize the sort for multiple data regions: You can design a report so that when the user toggles the sort order, other data regions with the same ancestor also sort.

For step-by-step instructions, see Add Interactive Sort to a Table or Matrix (Report Builder and SSRS).

The following table summarizes the effects you can achieve by using interactive sort buttons.

ActionWhat to sortWhere to add the sort buttonWhat to sort onSort scope
Sort detail rows for a table with no groupsDetailsColumn headerDataset field bound to this columnData region
Sort top-level group instances for a matrixGroupsColumn headerGroup expression for parent groupData region
Sort detail rows for a child group in a tableDetailsChild group header rowDataset field to sort byChild group
Sort rows for multiple row groups and detail rows in a tableGroups, but you must redefine the group expressionColumn headerAggregate of dataset field to sort byData region
Synchronize the sort order for multiple data regionsGroupsTypically, column headerGroup expressionDataset

The report processor applies interactive sort after all data region and group sort expressions are applied. For more information, see Filter, Group, and Sort Data (Report Builder and SSRS).

In a table with nested row groups each based on a single dataset field, you can add an interactive sort button that sorts parent group values, child group values, or detail rows. However, you might want to provide the user with the ability to sort the table by both the parent and child group values without having to click multiple times.

To do this, you must redesign the table to group on an expression that combines multiple fields. For example, for a dataset with inventory counts, if the original table grouped by size and then by color, you can specify a single group with a group expression that is a combination of size and color. For more information, see Add Interactive Sort to a Table or Matrix (Report Builder and SSRS).

Sort Data in a Data Region (Report Builder and SSRS)
Filter, Group, and Sort Data (Report Builder and SSRS)
Add Interactive Sort to a Table or Matrix (Report Builder and SSRS)

Community Additions