Drag the tables you need from the table panel to the workspace. The system will automatically link these tables together based on the first matching field name and data type.
Warning
The maximum number of tables per dataset is 32.
The maximum number of fields per dataset is 1,200.
Note
To use subqueries as a source, enable Raw SQL level → Subqueries only when creating or editing a connection.
Describing a dataset via a SQL query does not support parameters. However, you can use parameterized queries in QL charts.
In the table panel, click Add.
Enter a Source name and enter the SQL code in the Subquery field.
Click Create.
Example of an SQL query
An SQL query joins data from the samples.MS_SalesFacts, samples.MS_Products, and samples.MS_Shops tables and groups them by the Store and Product type fields. A sales total is calculated for each group; however, only the sales records from 2019 are used:
SELECT
t3.ShopName AS "Store",
t2.ProductCategory AS "Product type",
COUNT(t1.OrderID) AS "Number of sales",
SUM(t1.Price*t1.ProductCount) AS "Sales total"
FROM
samples.MS_SalesFacts t1
INNERJOIN samples.MS_Products t2 ON t2.ProductID=t1.ProductID
INNERJOIN samples.MS_Shops t3 ON t3.ShopID=t1.ShopID
WHERE
toYear(t1.OrderDatetime)='2019'-- Condition for selecting sales for the specified year (2019)GROUPBY "Store", "Product type" -- Grouping by Store and Product typeORDERBY "Store", "Product Type" -- Sorting by Store and Product type
When you merge data from multiple tables, a dataset will get duplicates of the fields used to create links. You can remove them manually from the list of dataset fields. You can also describe the dataset using an SQL query and exclude duplicate fields from the final set.
In the dataset, go to the Sources tab.
Click the table link icon.
Select the link type: inner, left, right, or full.
Select the fields to join the tables on. Hovering over a field displays a tooltip with the field full name. You can search fields by name.
You can only link fields with the same data type. DataLens gets information about the field's data type directly from the connection. If you need to join tables by fields with different data types, use one of these options:
Convert all the fields to the same data type at the source level.
SELECT*FROM lead INNERJOINuserON lead.assigned_by_id =CONVERT(user.external_id, CHAR)
If required, link other fields in the tables. To do this, click Add link.
Optionally, you can disable the Optimize link option to make the link required. In this case, the JOIN operation will be performed even if you select fields from a single table.
Click Apply.
By default, when you add a new table from a data source to the workspace, it is automatically linked to the first table listed there. If required, you can link a new table to a specific table. To do this, hover the new table over a previously added one and release when you see a gray border around the latter. A new link to the specified table is created.
You can replace a previously added table. When dragging a new table, hover it over the icon with circular arrows to the right of the table you are replacing for the icon background to turn blue, then release.
Note
If the updated table retains the same set of fields with the same names, the field IDs in the dataset will not change. In this case, the charts created based on this dataset will not be disturbed. If the updated table's schema has changed, update the dataset fields.
Optionally, enable Don't display in wizard to hide the field in the wizard when creating a chart.
Click Create. The field will appear in the dataset.
Enter a name for the field.
Go to the Field from source tab.
Specify the field parameters:
Field ID: ID of the field you are creating that is used to provide parameters for filtering by this field on the dashboard or in the chart URL. It may contain lowercase Latin letters, as well as the _ and - characters.
Source: Table in the data source with the field you need.
Source field: Field from the selected table in the data source.
You can duplicate any dataset field, including the calculated field you previously created. Proceed as follows:
On the right side of the field row, click (the icon appears when you hover over the row) and select Duplicate. In the list on the left, you will see a new field with the same type and settings as the original one.
Optionally, rename the duplicated field, change its type or formula.
You can perform the following operations on dataset fields:
Rename a field: To rename a field, click its current name and enter a new one.
Change the source: If the table schema in the source has changed, you can select a new field from the source to match the dataset field.
Change the field data type: Data type determines how to process data and which functions can apply to the field. To change the data type, click the current type and select a new one from the list of available types.
Select an aggregation type: Aggregation type determines the aggregation function to apply to the field. To change the aggregation type, click the current type and select a new one from the list of available aggregation types.
Setting up field display. For dimensions, you can choose a color and set a display format for numeric types; for metrics, you can only set a display format for numbers. These settings apply when you use these fields in charts built from this dataset.
Field display settings
Configure access permissions: You can restrict access to field values for different users or user groups. To do this, click and set the access configuration in 'field_value': user_email format. For more information, see Row-level security (RLS).
Sort fields: You can sort fields by name, data type, aggregation type, and other parameters. To do this, use the sorting buttons at the top of the Fields table.
Add a description: You can add a comment to a field in the Description column. This can help other users understand what the field is used for or how it is calculated.
Hide fields: You can hide fields you do not need at the moment. Other users will not see these fields in the wizard when creating a chart. To do this, click .
You need to update fields if you changed the schema of a table (or tables) in the data source or manually deleted fields from a dataset.
To update fields in a dataset:
In the dataset, go to the Fields tab.
At the top of the screen, click Update fields.
If a field is missing in the dataset but present in the data source, you will see that field in the list.
If a field is present in both the dataset and the data source, the field will be updated, e.g., its type will change.
If a field is present in the dataset but missing in the data source, that field will be marked in red. Delete it from the dataset or replace it with a different field from the data source.
If a field has been removed from a data source, it will not be updated when a dataset is updated. Charts featuring this field will show the ERR.DS_API.FORMULA.UNKNOWN_SOURCE_COLUMN error. You can delete this field from the chart or replace its source in the dataset.
To replace the field source in the dataset:
In the left-hand panel, click Datasets and select the dataset you need.
In the top-left corner, select the Fields tab.
In the dataset, select the field you want to replace.
Go to the Field source column.
In the field settings, select the field you wish to replace the deleted field with from the Field from source list.
You can select multiple dataset fields at once to delete, hide, or display them, change their type or aggregation.
To select the field range, hold the Shift key and set the beginning and end of the range with your mouse. You can select multiple ranges. To select each of the field ranges, hold Ctrl and click the first field in the range, then hold Shift and click the last field in the range.
To disable data export from charts based on a specific dataset, click in the upper right corner of the dataset and uncheck Allow data export.
Charts based on this dataset will no longer display the data export option in their menu, and users will be unable to export data from those charts. However, users will still be able to copy data from the charts and take screenshots.
To re-enable data export, click in the upper right corner of the dataset and check Allow data export.
Before deleting a dataset, check which objects are using it. To do this, at the top of the dataset, click → Linked objects. If an error appears when opening the linked object window, try clicking the Retry button.