A dataset contains information about leads, deals, companies, and other Bitrix24 items. Each item has several datasets that automatically receive data from system and custom fields. Use datasets to create charts and analyze business efficiency metrics.
In this article, you'll learn about datasets for leads, how to merge them, and how to create charts.
Datasets:
- crm_lead — leads
- crm_lead_uf — lead custom fields
- crm_lead_status_history — lead history
- crm_lead_product_row — products in leads
Examples:
Choose a dataset
To analyze information in a dashboard, choose a suitable dataset and create a chart.
crm_lead — leads. This dataset contains data from lead system fields, including names, statuses, responsible persons, clients, amounts, sources, and related items. Use this dataset to analyze how leads are handled and where customers come from.
crm_lead
| Field | Description | Data type |
|---|---|---|
| ID | Lead ID | Number |
| DATE_CREATE | Date and time the lead was created | Date and time |
| CREATED_BY_ID | ID of the employee who created the lead | Number |
| CREATED_BY | ID and name of the employee who created the lead | String |
| DATE_MODIFY | Date and time the lead was last modified | Date and time |
| MODIFY_BY_ID | ID of the employee who last modified the lead | Number |
| MODIFIED_BY | ID and name of the employee who last modified the lead | String |
| MODIFIED_BY_NAME | Name of the employee who last modified the lead | String |
| ASSIGNED_BY_ID | ID of the employee responsible for the lead | Number |
| ASSIGNED_BY | ID and name of the employee responsible for the lead | String |
| ASSIGNED_BY_NAME | Name of the employee responsible for the lead | String |
| ASSIGNED_BY_DEPARTMENT | Path in the department hierarchy of the responsible employee | String |
| COMPANY_ID | ID of the company linked to the lead | Number |
| COMPANY_NAME | Name of the company linked to the lead | String |
| COMPANY_TITLE | Company name specified in the lead form | String |
| COMPANY | ID and name of the company linked to the lead | String |
| CONTACT_ID | ID of the contact linked to the lead | Number |
| CONTACT_NAME | Name of the contact linked to the lead | String |
| CONTACT | ID and name of the contact linked to the lead | String |
| CONTACT_IDS | IDs of contacts linked to the lead | String |
| CONTACTS | IDs and names of contacts linked to the lead | String |
| OPENED | Shows whether the lead is available to everyone: Y — yes, N — no |
String |
| TITLE | Lead name | String |
| NAME | Client's first name in the lead form | String |
| LAST_NAME | Client's last name in the lead form | String |
| SECOND_NAME | Client's middle name in the lead form | String |
| FULL_NAME | Client's full name in the lead form | String |
| POST | Client's job title in the lead form | String |
| STATUS_ID | ID of the stage the lead is at | String |
| STATUS_NAME | Name of the stage the lead is at | String |
| STATUS | ID and name of the stage the lead is at | String |
| STATUS_DESCRIPTION | Additional information about the lead stage | String |
| STATUS_SEMANTIC_ID | ID of the stage group: F — failed, S — success, P — in progress |
String |
| STATUS_SEMANTIC | Name of the stage group: failed, success, in progress | String |
| IS_RETURN_CUSTOMER | Shows whether the lead is a repeat lead: Y — yes, N — no |
String |
| OPPORTUNITY | Expected amount of the lead | Number |
| IS_MANUAL_OPPORTUNITY | Shows whether the expected amount was entered manually: Y — yes, N — no |
String |
| CURRENCY_ID | Currency code of the lead | String |
| COMMENTS | Comment on the lead | String |
| WEBFORM_ID | ID of the CRM form the lead was created from | Number |
| SOURCE_ID | ID of the lead source | String |
| SOURCE_NAME | Name of the lead source | String |
| SOURCE | ID and name of the lead source | String |
| SOURCE_DESCRIPTION | Additional information about the lead source | String |
| ORIGINATOR_ID | ID of the external system where the lead was created | String |
| ORIGIN_ID | Lead ID in the external system | String |
| MOVED_BY_ID | ID of the employee who last changed the lead stage | Number |
| MOVED_TIME | Date and time the lead stage was last changed | Date and time |
| UTM_SOURCE | Advertising platform from the utm_source tag | String |
| UTM_MEDIUM | Ad type from the utm_medium tag | String |
| UTM_CAMPAIGN | Ad campaign from the utm_campaign tag | String |
| UTM_CONTENT | Additional information from the utm_content tag | String |
| UTM_TERM | Keyword from the utm_term tag | String |
| CRM_PRODUCT_ID | IDs of products in the lead form | String |
| CRM_PRODUCT | IDs and names of products in the lead form | String |
| CRM_PRODUCT_COUNT | Product quantity in the lead form | String |
| CRM_PRODUCT_NAME | Names of products in the lead form | String |
| ADDRESS_1 | Address in the lead form | String |
| ADDRESS_2 | Additional address in the lead form | String |
| ADDRESS_CITY | City | String |
| ADDRESS_POSTAL_CODE | Postal code | String |
| ADDRESS_REGION | Region | String |
| ADDRESS_PROVINCE | Province | String |
| ADDRESS_COUNTRY | Country | String |
| ADDRESS_COUNTRY_CODE | Country code | String |
| DATE_CLOSED | Close date of the lead | Date and time |
| BIRTHDATE | Client's date of birth | Date and time |
| HONORIFIC | Client's honorific | String |
| PHONE | Type and number of the client's phone | String |
| WEB | Type and address of the client's site | String |
| Type and address of the client's email | String | |
| IM | Messenger type and the client's contact information | String |
crm_lead_uf — lead custom fields. This dataset contains data from custom fields you create, such as delivery deadline and order number.
crm_lead_uf
| Field | Description | Data type |
|---|---|---|
| LEAD_ID | Lead ID | Number |
| DATE_MODIFY | Date and time the lead was last modified | Date and time |
| DATE_CREATE | Date and time the lead was created | Date and time |
| DATE_CLOSED | Close date of the lead | Date and time |
| UF_CRM_"field number" | Value of the custom lead field with the specified number. The system assigns a number to each field when you create it | String |
crm_lead_status_history — lead history. This dataset contains data about lead stage history, including records of creation and stage changes, dates, responsible employees, and statuses. Use this dataset to analyze a lead's path from creation to completion.
crm_lead_status_history
| Field | Description | Data type |
|---|---|---|
| ID | Record ID | Number |
| TYPE_ID | Record type: 1 — lead creation, 2 — transition to an intermediate stage, 3 — transition to a final stage |
Number |
| LEAD_ID | Lead ID | Number |
| DATE_CREATE | Date and time the record was created | Date and time |
| ASSIGNED_BY_ID | ID of the employee responsible for the lead | Number |
| ASSIGNED_BY | ID and name of the employee responsible for the lead | String |
| ASSIGNED_BY_NAME | Name of the employee responsible for the lead | String |
| ASSIGNED_BY_DEPARTMENT | Path in the department hierarchy of the responsible employee | String |
| STATUS_SEMANTIC_ID | ID of the stage group: F — failed, S — success, P — in progress |
String |
| STATUS_SEMANTIC | Name of the stage group: failed, success, in progress | String |
| STATUS_ID | Stage ID | String |
| STATUS | Stage ID and name | String |
| STATUS_NAME | Stage name | String |
crm_lead_product_row — products in leads. This dataset contains data about products and services in leads, including prices, quantities, discounts, taxes, currencies, and units of measurement. Use this dataset to analyze the composition and cost of products in leads.
crm_lead_product_row
| Field | Description | Data type |
|---|---|---|
| ID | Record ID | Number |
| LEAD_ID | Lead ID | Number |
| LEAD_DATE_MODIFY | Date and time the lead was last modified | Date and time |
| LEAD_DATE_CREATE | Date and time the lead was created | Date and time |
| LEAD_DATE_CLOSED | Close date of the lead | Date and time |
| PRODUCT | ID and name of the product or service | String |
| PRODUCT_ID | ID of the product or service | Number |
| PRODUCT_NAME | Name of the product or service | String |
| PRICE | Price of the product or service | Number |
| PRICE_EXCLUSIVE | Discounted price without tax | Number |
| PRICE_NETTO | Price without discounts or taxes | Number |
| PRICE_BRUTTO | Price without discounts, including tax | Number |
| QUANTITY | Quantity of the product or service | Number |
| SUM_NETTO | Amount for the product or service without discounts or taxes | Number |
| SUM_EXCLUSIVE | Amount for the product or service without tax, with discount | Number |
| SUM_TOTAL | Total amount for the product or service with discount and tax | Number |
| CURRENCY_ID | Lead currency used to calculate amounts for the product or service | String |
| DISCOUNT_TYPE | ID and name of the discount | String |
| DISCOUNT_TYPE_ID | Discount ID | Number |
| DISCOUNT_TYPE_NAME | Discount name | String |
| DISCOUNT_RATE | Discount rate, % | Number |
| DISCOUNT_SUM | Discount amount | Number |
| TAX_RATE | Tax rate, % | Number |
| TAX_INCLUDED | Shows whether tax is included in the price: Y — yes, N — no |
String |
| CUSTOMIZED | Shows whether the product or service was manually modified after being added to the lead: Y — yes, N — no |
String |
| MEASURE | ID and name of the unit of measurement | String |
| MEASURE_CODE | Unit of measurement code | Number |
| MEASURE_NAME | Unit of measurement name | String |
| SORT | Sort order of the product or service | Number |
Create a chart
Add information from a dataset to charts and track business metrics. Charts show which products sell more often and which ads attract clients.
- Open BI Builder > Charts.
- Click + Chart in the top-right corner.
- Choose a dataset from the list. If you do not see the dataset you need, click Add a dataset.
Create a dataset - Choose a chart type — the format for viewing the information, such as a card, table, line chart, or another option.
- Click Create new chart.
Merge datasets
Merge datasets to include information from a lead's system and custom fields in a report.
- Open BI Builder > SQL > SQL Lab.
- Make sure
bitrix24is selected in the Schema field. - Enter the SQL query and click Run.
- Review the query results. To create a chart for a report, save the query as a dataset. The dataset receives data from the fields specified in the SQL query.
Create a chart from a virtual dataset
If this is your first time merging datasets, see the sample queries.
Example SQL query: merging leads and custom fields
This SQL query extracts data from two datasets: leads (crm_lead) and custom lead fields (crm_lead_uf). You can copy it to see how the query works. Before running the query, replace UF_CRM_"field number" with your custom field.
SELECT
crm_lead.ID AS "Lead ID",
crm_lead.TITLE AS "Lead name",
crm_lead.DATE_CREATE AS "Date and time the lead was created",
crm_lead.OPPORTUNITY AS "Expected amount of the lead",
crm_lead_uf.UF_CRM_1726853107496 AS "Custom field"
FROM
crm_lead
INNER JOIN
crm_lead_uf ON crm_lead.ID = crm_lead_uf.LEAD_ID
WHERE
crm_lead_uf.UF_CRM_1726853107496 IS NOT NULL
AND crm_lead_uf.UF_CRM_1726853107496 <> ''
SELECT determines which information to extract from the dataset. For example, the query SELECT crm_lead.ID AS "Lead ID":
- Selects the lead ID
IDfrom thecrm_leaddataset - Assigns it the name
Lead ID - Displays the result in a separate table column
FROM specifies the main dataset that the data comes from. This query extracts data from crm_lead.
INNER JOIN links datasets and combines their information. The query crm_lead_uf ON crm_lead.ID = crm_lead_uf.LEAD_ID links system and custom field information by lead ID.
WHERE filters the results and shows only leads with a non-empty custom field.
Example SQL query: getting a list of leads converted into deals
To assess how many leads convert into deals, extract data from two datasets: leads (crm_lead) and deals (crm_deal). This SQL query shows the deal each lead was converted into during the last 30 days. You can copy it to see how the query works.
SELECT
crm_lead.ID AS "Lead ID",
crm_lead.TITLE AS "Lead name",
crm_lead.DATE_CREATE AS "Date and time the lead was created",
crm_deal.ID AS "Deal ID",
crm_deal.TITLE AS "Deal name",
crm_deal.DATE_CREATE AS "Date and time the deal was created"
FROM
crm_lead
INNER JOIN
crm_deal ON crm_lead.ID = crm_deal.LEAD_ID
WHERE
crm_deal.DATE_CREATE >= date_add('day', -30, current_date)
SELECT determines which information to extract from the dataset. For example, the query SELECT crm_lead.ID AS "Lead ID":
- Selects the lead ID
IDfrom thecrm_leaddataset - Assigns it the name
Lead ID - Displays the result in a separate table column
FROM specifies the main dataset that the data comes from. This query extracts data from crm_lead.
INNER JOIN links datasets and combines their information. The query crm_deal ON crm_lead.ID = crm_deal.LEAD_ID:
- INNER JOIN crm_deal — joins the
crm_leadtable to thecrm_dealtable - ON crm_lead.ID = crm_deal.LEAD_ID — adds a join condition: the lead ID in the
crm_lead (ID)table must match the lead ID in thecrm_deal (LEAD_ID)table. This links each lead to the deal it was converted into
WHERE filters the results and selects only records that meet the specified conditions. The query crm_deal.DATE_CREATE >= date_add('day', -30, current_date):
- Calculates the date 30 days before today using the
date_add('day', -30, current_date)function - Compares the deal creation date
(crm_deal.DATE_CREATE)with the calculated date - Selects only deals created in the last 30 days. This means the selection includes leads converted into deals during the past month
In brief
- A dataset contains information about leads, deals, companies, and other Bitrix24 items.
- Each item has several datasets that automatically receive data from system and custom fields.
- Leads have four datasets: leads (crm_lead), custom fields (crm_lead_uf), lead history (crm_lead_status_history), and products in leads (crm_lead_product_row).
- Use datasets to create charts and analyze business efficiency metrics. Charts can show which products sell more often or which ads attract clients.
- Merge datasets to include information from lead system and custom fields in a report. Write an SQL query, save the result as a dataset, and create a chart.