New to Telerik Reporting? Download free 30-day trial

Getting Started with the Crosstab Report Item

The Telerik Reporting Crosstab is a template variation of the Telerik Reporting Table report item, the difference between the two being that the Crosstab uses grouped data. As a result, the Crosstab is more frequently used in real-case scenarios and its Wizard provides more options for manipulating its data than the Table Wizard does.

Therefore, this guide shows how to create and use the Telerik Reporting Crosstab report item in reports with the Telerik Reporting Standalone Report Designer. Note that the Crosstab Wizard of the Standalone Report Designer is identical to the Table Wizard, except for the grouping and total aggregates options, and, if required, you can add a Table instead of a Crosstab to your report by following the same steps from this guide.

  • First, you will add a Crosstab item in an empty report created with the Standalone Designer. You will use the Crosstab Wizard for this purpose.
  • Following the instructions in the wizard, you will create an SqlDataSource to feed the Crosstab with data.
  • With the wizard, you will also create one Row and one Column Group without Totals.
  • Finally, you will manually add some minor adjustments to the layout of the CrossTab.

After the completion of this guide, you will also be able to configure a Crosstab in the Standalone Designer and achieve the following result:

Manually adjusting the Crosstab in Standalone Designer - Preview

Adding the Crosstab

To add the Crosstab report item to your report,

  1. Open the Standalone Report Designer.
  2. Add a new Blank report item.
  3. Select the Detail section of the new report and, from the Standalone Designer Menu, select Insert.
  4. Use the Crosstab button from the toolbar and, then, the Crosstab Wizard option from the drop-down to open the CrossTab wizard:

    Open the Crosstab Wizard in the Standalone Designer

  5. In the Crosstab wizard, click the Add New Data Source... button. As a result, the Create New Data Source wizard will open.

Configuring the CrossTab SqlDataSource

  1. From the list with the available DataSource components, select SqlDataSource and name it crosstabSqlDataSource.
  2. Populate the report with data.

    For the purposes of this demo, you will use the following query from the AdventureWorks sample database:

    SELECT
        [Production].[Product].[Name] AS 'ProductName', 
        [Production].[ProductCategory].[Name] AS 'ProductCategory', 
        [Production].[ProductSubcategory].[Name] AS 'ProductSubCategory', 
        [Sales].[SalesOrderDetail].[LineTotal], 
        [Sales].[SalesOrderHeader].[OrderDate]
    FROM (((([Sales].[SalesOrderDetail]
        INNER JOIN [Sales].[SalesOrderHeader]
        ON [Sales].[SalesOrderDetail].[SalesOrderID] = [Sales].[SalesOrderHeader].[SalesOrderID])
        INNER JOIN [Production].[Product]
        ON [Sales].[SalesOrderDetail].[ProductID] = [Production].[Product].[ProductID])
        INNER JOIN [Production].[ProductSubcategory]
        ON [Production].[Product].[ProductSubcategoryID] = [Production].[ProductSubcategory].[ProductSubcategoryID])
        INNER JOIN [Production].[ProductCategory]
        ON [Production].[ProductSubcategory].[ProductCategoryID] = [Production].[ProductCategory].[ProductCategoryID])
    
  3. Preview the returned data and close the SqlDataSource wizard.

Configuring the Crosstab

  1. Return to the Crosstab Wizard to see the fields of the recently created SqlDataSource. The image below shows how the data source will look like:

    Choose a Data Source in the Crosstab Wizard in the Standalone Designer

  2. Click Next and continue to the Arrange Fields page of the wizard. Drag and drop the fields as follows:

    • ProductSubCategory to the Row Groups.
    • OrderDate.Year to the Column Groups.
    • ProductName to the Detail Values. This will automatically apply the Count aggregate function to the value.
    • LineTotal to the Detail Values. This will automatically apply the Sum aggregate function to the value.

    The following screenshot shows this configuration step:

    Arrange Fields in the Crosstab Wizard in the Standalone Designer

  3. Go to the next Choose Layout page. Let's leave its default layout as shown below:

    Choose Layout in the Crosstab Wizard in the Standalone Designer

  4. On the Choose Style page, select a theme for the Crosstab layout. Let's try the Office theme:

    Choose Office Style in the Crosstab Wizard in the Standalone Designer

  5. Click Review Summary to see the result. Then, click Finish to close the wizard:

    Review Summary in the Crosstab Wizard in the Standalone Designer

After the wizard closes, you will have a fully configured Crosstab in the middle of the Report Detail section:

Crosstab in design view after finishing the Crosstab Wizard in the Standalone Designer

Fine-Tuning the Layout

If you are not planning to add other components to your project, drag the Crosstab so that it starts from the top left corner of the report Detail section and collapse the detail section of your report.

You can also delete the PageHeader and PageFooter sections that were added by default. The following image shows the Design view of the Crosstab after these changes:

Manually adjusting the Crosstab in Standalone Designer - Design view

Next Steps

See Also

In this article