---
title: Example - creating a simple report
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

This example demonstrates how to create a report that displays a table, graph and value, and uses a reporting parameter:

## Creating a report category

1. Open the **Reporting** application.
2. Select the root of the reporting tree (the **All reports** category by default).
3. Click **...** next to the **New report** button and select **New category**.
4. Type _Custom reports_ as the **Category display name**.
5. You can leave the code name as _(automatic)_.
6. Click **Save**.

## Creating a new report

1. In the **Reporting** application (with the _Custom reports_ category selected), click **New report**.
2. Type _Pages by type_ as the **Report display name**.
3. Click **Save**.
   - Now you can edit the layout of the report and insert tables, graphs and values.
   - The **General** tab of the report editing interface opens.
4. Type _Pages by type_ into the **Layout** text area.
5. Select the text and use the editor to set the **Format** to _Heading 1_.

   ![Adding the heading into the report's layout](https://docs.kentico.com/docsassets/13/example-creating-a-simple-report/New_Report.png "Adding the heading into the report's layout")
6. Click **Save**.

### Creating a new table

1. On the report's **General** tab, click **New** in the **Tables** section below the layout editor.
2. Enter the following values:
   - **Display name**: Pages by type
   - **Query**:

     ```sql

     SELECT ClassDisplayName AS [Page type], NodeAliasPath AS [Page], DocumentCulture AS [Culture]
      FROM View_CMS_Tree_Joined
      ORDER BY ClassDisplayName

     ```
   - **Is stored procedure:** no (cleared)
   - **SkinID**: ReportGridAnalytics
   - **Enable paging**: yes (selected)
   - **Page size**: 10
   - **Page mode**: Page numbers
3. Click **Save & Close**.
4. Place the cursor in the layout editor on a new line under the heading.
5. Select the table from the list in the **Tables** section.
6. Click **Insert**.
   - The system adds a string like _%%control:ReportTable?PagesByType.PagesByType%%_ into the text area.
7. Click **Save**.

Switch to the **View** tab to see the report table.

![Viewing the new report table](https://docs.kentico.com/docsassets/13/example-creating-a-simple-report/Report_Table.png "Viewing the new report table")

### Creating a new graph

1. Switch back to the report's **General** tab.
2. Click **New** in the **Graphs** section below the layout editor.
3. Enter the following values:
   - **Display name:** Favorite page types
   - **Query:**

     ```sql

     SELECT TOP 5 ClassDisplayName AS [Page type], COUNT(ClassDisplayName) AS [Usage]
      FROM View_CMS_Tree_Joined
      GROUP BY ClassDisplayName
      ORDER BY COUNT(ClassDisplayName) DESC

     ```
   - **Graph type**: Pie chart
   - **Drawing style**: Pie
   - **Title**: Favorite page types
   - **Series -> Display item value**: no (cleared)
4. Click **Save & Close**.
5. Place the cursor in the layout editor on a new line under the table.
6. Select the graph from the list in the **Graphs** section.
7. Click **Insert**.
   - The system adds a string like _%%control:ReportGraph?PagesByType.FavoritePageTypes%%_ into the text area.
8. Click **Save** to save the changes.

If you now switch to the **View** tab, you can see the report graph.

![Viewing the new report graph](https://docs.kentico.com/docsassets/13/example-creating-a-simple-report/Report_Graph.png "Viewing the new report graph")

### Creating new values

1. Switch back to the report's **General** tab.
2. Click **New** in the **Values** section below the layout editor.
3. Enter the following values:
   - **Display name:** Total pages
   - **Query:**

     ```sql

     SELECT COUNT(DocumentID)
      FROM View_CMS_Tree_Joined


     ```
   - **Is stored procedure**: no (cleared)
   - **Formatting string**: Total number of pages: {0}
4. Click **Save & Close**.
5. Place the cursor in the layout editor under the graph.
6. Select the new value from the list in the **Values** section.
7. Click **Insert**.
   - The system adds a string like _%%control:ReportValue?PagesByType.TotalNumberOfPages%%_ into the text area.
8. Click **Save**.

If you switch to the **View** tab, you can see the text of the value.

## Defining report parameters

1. Switch to the **Parameters** tab.
2. Click **New field** and enter the following values:
   - **Field name:** UserID
   - **Data type:** Integer number
   - **Default value:** 53
   - **Field caption:** Created by user
   - **Form control:** User selector
3. Click **Save**.

Now you need to add the parameter to your queries. For the purposes of this example, modify only the table query.

1. Switch to the **General** tab.
2. Select **Pages by type** in the **Table** list.
3. Click **...** next to the **New** button and select **Edit**.
4. Modify the table SQL query like this:

   ```sql

   SELECT ClassDisplayName AS [Page type], NodeAliasPath AS [Page], DocumentCulture AS [Culture]
    FROM View_CMS_Tree_Joined
    WHERE DocumentCreatedByUserID = @UserID
    ORDER BY ClassDisplayName

   ```

   > **Info:** This adds the parameter to the WHERE condition of the query. All parameters that you define can be used in the query using the @ expression.
5. Click **Save & Close**.

Now switch to the **View** tab. You can see that the report has a filter:

![Viewing the filter that allows you to set value of the report's parameter](https://docs.kentico.com/docsassets/13/example-creating-a-simple-report/Report_Filter.png "Viewing the filter that allows you to set value of the report's parameter")

The table now only displays the types for pages that were created by the user specified in the filter.
