Joining DataLens data
DataLens uses a connection to retrieve data from a source. You can create datasets, charts, and selectors from the connection data. If the source has multiple tables, you can join them to build the required set of data. You can link data from different datasets at the chart level or through selector links.
Data joining methods
You can use different data joining methods:
Dataset level
To join data at the dataset level, you can add tables to the workspace or write an SQL query.
Warning
You cannot join data from different sources at a single dataset level.
Adding tables
You can join data through the dataset creation interface by dragging tables to the workspace and configuring links between them using the JOIN operator.
Note
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.
SQL query
In a dataset, you can add an ad-hoc SQL query to the data source. When accessing a data source, the query code is run as a subquery. You can use the output of the query as final dataset data or combine it with other source tables via the interface.
Chart level
To combine data at the chart level, you can use a QL chart.
QL chart
QL charts are charts created from a connection if there is a database at the other end of the connection. Running a SQL query does not create a separate dataset object; instead, it generates one on the fly and displays it in the preview panel. For more information, see Creating a QL chart.
Selector link level
You can add a selector to a dashboard to modify query output in its associated widgets:
- On the dashboard, selectors and charts built from a single dataset get linked automatically.
- Selectors and charts built from different datasets can be linked manually using aliases.
Before creating a link, make sure the field used by the selector as a filter is included in the dataset the chart is built from. Otherwise, the link will not work. For more information, see the instructions Creating an alias.