Creating and editing a widget
Create custom reports in the Pyrus form Dashboard. You have access to both simple reports and interactive ones that change dynamically based on the filters you select.

Create a new widget
Let's look at how to create a widget in a form Dashboard. How to add a widget to a separate report is described in the article How to create a report and share access to it.
Note: to create and edit SQL widgets in a form Dashboard, you need Manager or Administrator rights for the form and access to all of its fields.
More about user rights in forms
Step 1. Choosing the display type and preparing data
Before writing a query, decide what your final report will look like. This choice will define the structure of your SQL query and the format of the data you extract from the Pyrus form fields.
You can choose one of these display types:
- table;
- pie chart;
- bar chart;
- time series.
Widgets are built only from the data you selected in SELECT, so make sure your selection is correct. Detailed requirements for each chart type are described here. Read them to understand the data format a chart requires.
Step 2. Adding a widget to the Dashboard
Widgets created with an SQL query for a specific form are collected in the Dashboard section of that form. These custom widgets are placed above the standard Pyrus widgets.
To create a new widget, do the following:
Open the Dashboard section of the form you need.

Click Add widget in the upper-right corner of the screen.

The widget editor opens. The editor window is split into two parts. The upper part displays the query results, and the lower part is for entering the query.
Enter an SQL query written in the ClickHouse dialect and click Execute.

The query will return an analytical table, chart, etc., depending on the selected display type.
Widget example
As an example, let's create a widget that shows who created how many tasks from the form over the last seven days.
Enter the following SQL query in the editing block at the bottom of the screen:
SELECT creator_id, COUNT(task_id) FROM #tasks WHERE DATE(create_date) >= DATE(now()) - 7 GROUP BY creator_id ORDER BY COUNT(task_id) DESC LIMIT 100;
Click Execute. You will see a table with the number of tasks created by different employees over the last seven days. LIMIT 100 limits the result to one hundred creators.

Step 3. Adding aliases
By default, the column names of the table and identifiers in the dataset correspond to the names of the variables added in SELECT. If you want the report data to be displayed differently, for example with different column names, use aliases.
Read here for more details on what aliases are and how to apply them in Pyrus custom reports.
Example of a widget with renamed columns and data in the table
Add aliases to your SQL query and click Execute.
SELECT
creator_id AS "#person_full_name('Creator')",
COUNT(task_id) AS "Tasks created"
FROM #tasks
WHERE DATE(create_date) >= DATE(now()) - 7
GROUP BY creator_id
ORDER BY COUNT(task_id) DESC
LIMIT 100;
After the query is executed, the table will show the headers Creator and "Tasks created", and employee names instead of IDs. The number of tasks stays the same.

Step 4. Adding parameters
To make the widget respond to Dashboard filters, use parameters in the query. They substitute filter values into the query, for example the selected period or task statuses. When the user changes a filter, the widget data is recalculated.
Example of using the period and filters
Let's look at how to create a widget that shows the number of tasks and the total request value for each creator, taking into account the active Dashboard filters.
The example uses the Value of request field of the Money type. In your query, replace ${Value of request} with the code or name of a Money field in your form.

Enter a query with SQL parameters in the lower part of the editor:
SELECT
creator_id AS "#person_full_name('Creator')",
SUM(${Value of request}) AS "Total",
COUNT(task_id) AS "Tasks created"
FROM #tasks
WHERE
create_date >= @period_start
AND create_date <= @period_end
AND #task_filters
GROUP BY creator_id
ORDER BY COUNT(task_id) DESC
LIMIT 100;
Click Execute. You will see how many tasks each creator created over the selected period and their total value. If you change the period in the Dashboard, the data is recalculated: the @period_start and @period_end parameters take their dates from the filter. The #task_filters parameter applies the other Dashboard filters, for example by status or assignee.
Step 5. Checking and saving the widget
- Check the query result in the upper part of the editor. The numbers should match the form data. For example, the number of tasks in the widget should be the same as in the form's task list with the same filters.
- If necessary, change the chart type and value format, hide the table, or group the rows. How to do this is described in the article Configuring and using widgets, in the section Configuring the widget appearance.
- Click Save in the upper-right corner of the editor. Make sure the widget appears in the Dashboard.

If the query does not run, fix it according to the error message in the editor.
How to reference form fields in a query and what restrictions apply is described in the SQL reference. The data each chart type requires is described in the data types reference.
Editing a widget
Open the form Dashboard or the report with the widget you need.
Hover over the widget and open the three-dot menu.
Click Settings.

Make your changes. If you changed the SQL query, click Execute and check the result. You can change the widget's appearance without editing the query if the data suits the selected display type.
Click Save.
Deleting a widget
Open the Dashboard.
Hover over the widget you need and click the three dots.
Click Delete widget.

If you need to temporarily remove a widget from the screen, hide it in the widget settings.
How to do this is described in the article Configuring and using widgets, in the section Hiding and restoring a widget.
What's next?
You can keep the query result as a table or show it as a chart. How to choose a chart type, set the value format, value highlighting, grouping, and totals, and how to change the order of widgets in the Dashboard is described in the article Configuring and using widgets.
To collect widgets for different forms on one page and give colleagues access to them, create a report.
How to reference form fields and parameters in a query is described in the SQL reference. Ready-made queries for common tasks are collected in the report examples.