Bitrix24 Helpdesk

BI Builder: Configure filters by flows and workflow templates

In the BI Builder, you can use filters based on parameters like task flows and workflow templates. These filters help analyze data in the desired context, such as focusing on a specific flow or an individual workflow template.

Filters work with report parameters and automatically adjust data depending on where the report is opened. For example, if a report is opened from the "Legal Department" flow, the filter will immediately apply and display tasks only for this team.

In this article:


Set parameters for a report in Bitrix24

Before adding filters, you need to configure parameters. These parameters establish a connection between the report and the data. For example, the parameter tasks_flows_flow_id passes the task flow ID, while bworkflow_template_id passes the workflow template ID. These parameters can be set for both new and existing reports:

  1. Go to the BI Builder section.
  2. To create a report, click New report.
  3. To edit an existing report, open Menu (≡) > Settings.

When creating a report, specify its name, add it to the groups where it will be displayed, and set the required parameters.

After adding a parameter, you can choose whether to display the report in the corresponding section. For example, if you use the flow ID parameter, the report will be accessible by clicking the flow status. If you add the workflow template ID, the report will appear in the workflow protocol form.

After specifying the parameters, they need to be added to the dataset. Charts in the report are built based on the dataset, so the parameters must be included in the query. If parameters are not added, they will not function. Open the Parameter Identifiers section and record the codes of the required variables to use them in the dataset.


Create or update a dataset

If you are creating a new report, you can specify parameters directly in the SQL query.

  1. Click SQL tab > SQL Lab.
  2. Select the bitrix24 schema.
  3. Enter the SQL query and click Execute. Add a Jinja template to the query to ensure the report correctly applies the filter value. For example, if the report is opened fr om a workflow protocol, Jinja will substitute its ID, and the report will display only data for that process. If the report is opened separately, the filter will not receive an ID and will display all data.

Using Jinja Templates in BI Builder

If you are creating a dataset for the first time, check out an example query.

Example of SQL query for task flow reports

This is an SQL query to extract data from the task flow dataset (flow). You can copy it and see how the selection works. The query displays the main fields of the flow and supports filtering by the tasks_flows_flow_id parameter.

 SELECT f.id AS "Flow ID", f.name AS "Flow Name", f.creator_name AS "Flow Creator Name", f.planned_completion_time AS "Task Completion Time", f.tasks_ids AS "Tasks in Flow" FROM flow f WHERE 1=1 {% if url_param('tasks_flows_flow_id') is not none %} AND f.id = {{ url_param('tasks_flows_flow_id') }} {% endif %} 

SELECT specifies the information to extract from the dataset. For example, the query SEL ECT f.id AS "Flow ID":

  • Selects the flow id from the flow dataset.
  • Assigns it the name Flow ID.
  • Displays the result in a separate column in the table.

FROM specifies the dataset from which data is extracted. We extract from flow, which is a table containing task flow information.

WHERE filters the results. The base condition 1=1 is used to conveniently add additional constraints.

Next, a Jinja template is used. This part checks if the tasks_flows_flow_id parameter is present in the report. If the report is opened from a flow, Jinja substitutes its ID and displays only data for that flow. If the report is opened directly in the BI Builder, the parameter is not passed, and all data is displayed.

Example of SQL query for workflow template reports

This is an SQL query to extract data from three datasets: workflow tasks (bizproc_task), active workflows (bizproc_workflow_state), and workflow templates (bizproc_workflow_template). You can copy it and see how the selection works. The query displays key information about active workflows and supports filtering by the workflow_template_id parameter, allowing the report to be built for a specific process template.

 SELECT t.created_date AS "Task Creation Date", t.status_name AS "Task Status", t.user_name AS "Task Participant", w.started_by_name AS "Process Initiator", w.completed AS "Process Completion Status", w.duration AS "Time Spent", wt.name AS "Template Name" FROM bizproc_task t LEFT JOIN bizproc_workflow_state w ON t.workflow_id = w.id LEFT JOIN bizproc_workflow_template wt ON wt.id = w.workflow_template_id WHERE 1=1 {% if url_param('workflow_template_id') is not none %} AND wt.id = {{ url_param('workflow_template_id') }} {% endif %} ORDER BY t.created_date DESC; 

SELECT specifies the data to extract fr om the datasets. For example, the query SELECT t.created_date AS "Task Creation Date":

  • Selects the task created_date from the bizproc_task dataset,
  • Assigns the field the Task Creation Date name
  • Displays the result in a separate column in the table.

FROM and LEFT JOIN specify the datasets from which data is taken and how they are related.

  • bizproc_task contains tasks performed by employees,
  • bizproc_workflow_state stores data about the process within which the task was created,
  • bizproc_workflow_template describes the workflow template.

LEFT JOIN is used to display all tasks, even if some lack state or template information.

WHERE filters the results. The condition 1=1 does not affect the selection and is used to simplify adding filters.

Next, a Jinja template is used. This part checks if the workflow_template_id parameter is present in the report. If the report is opened fr om a workflow protocol form, Jinja substitutes the ID and displays only related data. If the report is opened directly in the BI Builder, the parameter is not passed, and all data is displayed.

Save the resulting dataset as a dataset and create a chart for the report.
Create a chart based on a virtual dataset

If you already have a report, you can simply edit the dataset and add the required parameter.

  1. Open the Datasets tab, and select one of them.
  2. Click Edit.

Modify the SQL query and add the parameter depending on the filter you plan to use:

  • Task flows — WHERE 1=1 {% if url_param('tasks_flows_flow_id') is not none %} AND f.id = {{ url_param('tasks_flows_flow_id') }} {% endif %}.
  • Workflow templates — WHERE 1=1 {% if url_param('workflow_template_id') is not none %} AND wt.id = {{ url_param('workflow_template_id') }} {% endif %}.

Add filters and test the report

To add filters:

  1. Open the report in edit mode.
  2. Click Add/modify filters in the left panel.
  3. Specify the required type and name, and save the settings.

Test how the filters work. To do this, open the report in the section where it was embedded. The location depends on the selected parameters:

Workflow templates

  1. Go to the Automation section > Workflows.
  2. Select the required workflow and open the report in the Journal tab.

Task flows

  1. Go to the Tasks and Projects > Flows.
  2. In the Analytics column, click the flow metric and open the report.

In brief

  • Filters based on parameters help analyze data in the desired context, such as for a specific task flow or workflow template.

  • To use filters, configure the report parameters and specify the section where it will be opened.

  • If creating a new report, you can add parameters directly to the SQL query. If the report already exists, edit the dataset to add parameters.

  • Afterward, add filters to the report, open it in Bitrix24, and ensure it displays data only for the selected flow or process.
Was this information helpful?
Integration specialist assistance
That's not what I'm looking for
Complicated and incomprehensible text
The information is outdated
It's too short. I need more information
I don't like the way this tool works
Get your Bitrix24 set up by local professionals
FIND BITRIX24 PARTNER NEAR ME
implementation_helper_man
Go to Bitrix24
Don't have an account? Create for free
Related articles
Description of datasets and fields for BI Builder Edit dashboards in BI Builder BI Builder: Date filters in SQL query BI Builder: How to update report data Blend deals, products, and product properties into a BI Builder dataset BI Builder: SQL functions for advanced query analysis Using Jinja Templates in BI Builder Customize ready BI Builder dashboards Create dashboards in BI Builder Configure dashboard parameters in BI Builder