ActiveReports 13
Sorting
ActiveReports 13 > ActiveReports User Guide > Concepts > Interactive Features > Sorting

In order to better organize and present data in your report, you can sort it alphabetically or numerically in ascending or descending order. You can also use sorting effectively with grouped data to present an easy to understand, comprehensive view of report data.

Sorting in Page Reports/RDL Reports

In a page report or a RDL report, you can sort data in the data region, along with grouping, on a fixed page in Page report or sort data directly in the SQL query. You can also set interactive sorting for your data on a TextBox control.

Sorting at different levels in a Report

You can apply sorting at different levels on your report data. ActiveReports provides a Sorting page in the dialogs of a data region, grouped data and fixed page to determine where you want to display sorted data.

Sorting data in a Data Region

In Table and List data regions, you can sort data within the data region. To sort data within these data regions, set sorting in the Sorting page of the specific data region's dialog.

In Tablix, BandedList and Chart data regions, sorting is only possible on grouped data therefore there is no independent Sorting page available in their specific dialogs.

Sorting grouped data

A Sorting tab is available inside the Groups page of all the data region dialogs and the Detail Grouping page of the List dialog. It allows you to set the sort order of grouped data. This tab is enabled once grouping is set inside the data region.

Sorting on a Fixed Page

In a Page report, sorting is also possible on a fixed page grouped on a dynamic value. Sorting data on a fixed page is similar to sorting grouped data in a data region. The only difference is when you sort data on the fixed page you apply sorting to all the data regions that are placed on the design surface. See, Sort Data for more information.

Sorting data through SQL Query

When you connect to a data source and create a data set to fetch data for your report, you define a query. Set the ORDER BY keyword in the query to sort data in ascending or descending order.

By default, the ORDER BY keyword usually sorts the data in ascending order, but you can include the DESC keyword in your query to sort data in descending order. For example, if you want to fetch data from the Movie table of the Reels database and sort it on the Title field, your query looks like the following:
SELECT * FROM Movie ORDER BY Title
OR
SELECT * FROM Movie ORDER BY Title ASC

In case you want the Title field sorted in descending order, your query looks like the following:
SELECT * FROM Movie ORDER BY Title DESC

Interactive Sorting

You can add interactive sorting on a TextBox control to allow users to sort columns of data within a data region on a published report.

The interactive sorting feature is set through the Interactive Sort page which available in the TextBox dialog.

Once you set interactive sorting on a TextBox control, while viewing the report in the Viewer or in the Preview Tab the textbox control displays a sort icon inside it. A user can sort data that appears inside the textbox in ascending or descending order by clicking the icons.

On the Interactive Sort page of the TextBox dialog you can find following fields available for entering values:

See Allow Users to Sort Data in the Viewer for more information.

Sorting in Section Reports

In a section report, sorting is not explicitly available. However, you can modify the SQL Query to order your data while fetching it from the database.

Sorting data through SQL Query

When you connect the report to a data source and enter a query to fetch data, you can include the ORDER BY keyword in your query to get sorted data.

By default, the ORDER BY keyword usually sorts data in ascending order, but you can include the DESC keyword in your query to sort data in descending order. For example, if you want to fetch data from the Customers table of the NWind database and sort it on the CompanyName field, your query looks like the following:
SELECT * FROM Customers ORDER BY CompanyName
OR
SELECT * FROM Customers ORDER BY CompanyName ASC

In case you want the CompanyName field sorted in descending order, your query looks like the following:
SELECT * FROM Customers ORDER BY CompanyName DESC

See Also

How To