# Getting Started with the Crosstab

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](https://www.telerik.com/products/reporting/documentation/designing-reports/report-designer-tools/desktop-designers/standalone-report-designer/overview). 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:

![Preview of a report with Crosstab in the Standalone Report Designer](https://www.telerik.com/products/reporting/documentation/assets/ed13a06d541993ee55f458e041003ea0/crosstabmanualadjustpreview.png)

## 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](https://www.telerik.com/products/reporting/documentation/report-items/report-item/get-started).

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 from the File menu of the Standalone Report Designer](https://www.telerik.com/products/reporting/documentation/assets/3fbb6119caca449f13edbf55ff6ef099/crosstabwizardstart.png)

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](https://www.telerik.com/products/reporting/documentation/getting-started/first-steps-designing#step-3-populate-the-report-with-data).

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

   ```SQL
   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 of the Standalone Report Designer](https://www.telerik.com/products/reporting/documentation/assets/3427a39c1d299c78a5a50b40ea29bfac/crosstabwizardchoosedatasource.png)

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](https://www.telerik.com/products/reporting/documentation/designing-reports/connecting-to-data/expressions/expressions-reference/functions/aggregate-functions) 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 Row groups, Column groups and Detail values in the Crosstab Wizard of the Standalone Report Designer](https://www.telerik.com/products/reporting/documentation/assets/f74df24da8146d3f3db8a1bb3e7b3e9d/crosstabwizardarrangefields.png)

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

   ![Choose Layout in the Crosstab Wizard of the Standalone Report Designer](https://www.telerik.com/products/reporting/documentation/assets/a9b55fccc2fbd68ff3562416ea6775e6/crosstabwizardchooselayout.png)

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 of the Standalone Report Designer](https://www.telerik.com/products/reporting/documentation/assets/9a58e4ab863e5ba791b5c66a589699be/crosstabwizardchooseofficestyle.png)

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

   ![Review the configuration Summary in the Crosstab Wizard of the Standalone Report Designer](https://www.telerik.com/products/reporting/documentation/assets/b601cc2a7631a2b0ff85386841ca8cf9/crosstabwizardreviewsummary.png)

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 of the Standalone Report Designer](https://www.telerik.com/products/reporting/documentation/assets/1da7a3e151bb0867a6396c940821d853/crosstabafterwizarddesign.png)

## 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:

![Design view of the Crosstab after adjusting it manually in the Standalone Report Designer](https://www.telerik.com/products/reporting/documentation/assets/5f8f2765cf952ee94f23851e0877385c/crosstabmanualadjustdesign.png)

## Next Steps

* [Manually Adjusting the CrossTab](https://www.telerik.com/products/reporting/documentation/report-items/table-crosstab-list/manual-adjustment)
* [(Demo) Product Sales Report with a Crosstab Summary](https://demos.telerik.com/reporting/product-sales)
* [(Demo) List-Bound Report](https://demos.telerik.com/reporting/list-bound-report)
* [Basic Concepts of the Table, Crosstab, and List](https://www.telerik.com/products/reporting/documentation/report-items/table-crosstab-list/basic-concepts)
* [Table Class API Reference](https://www.telerik.com/products/reporting/documentation/api/telerik.reporting.table)
* [Demo Page for Telerik Reporting](https://demos.telerik.com/reporting)
* [Telerik Reporting Knowledge Base](https://www.telerik.com/products/reporting/documentation/knowledge-base)

## See Also

* [Standalone Report Designer](https://www.telerik.com/products/reporting/documentation/designing-reports/report-designer-tools/desktop-designers/standalone-report-designer/overview)
* [Report Getting Started](https://www.telerik.com/products/reporting/documentation/report-items/report-item/get-started)
* [Group Explorer](https://www.telerik.com/products/reporting/documentation/designing-reports/report-designer-tools/desktop-designers/tools/group-explorer)
* [Aggregate Functions](https://www.telerik.com/products/reporting/documentation/designing-reports/connecting-to-data/expressions/expressions-reference/functions/aggregate-functions)
