Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex DataLens
  • DataLens neuroanalyst
    • Overview
      • Using parameters in calculated fields
      • Source parameterization
      • Examples of creating QL charts
  • DataLens Gallery
  • Audit Trails events

In this article:

  • Getting started
  • Create a workbook
  • Create a connection
  • Create a dataset with a table substitution parameter
  • Create a chart with a table selection parameter
  • Create a dataset with a subquery parameter
  • Create a chart with a parameter for selecting a subquery condition
  1. Tutorials
  2. Functional
  3. Source parameterization

Source parameterization in DataLens

Written by
Yandex Cloud
Updated at September 17, 2025
  • Getting started
  • Create a workbook
  • Create a connection
  • Create a dataset with a table substitution parameter
  • Create a chart with a table selection parameter
  • Create a dataset with a subquery parameter
  • Create a chart with a parameter for selecting a subquery condition

Note

In this tutorial all objects will be created and stored in a workbook. If using legacy folder navigation, create an individual directory to work in.

Create a directory
  1. Go to the DataLens home page.
  2. In the left-hand panel, select All objects or Personal directory.
  3. In the top-right corner, click Create → Directory.
  4. Enter a name for the directory.
  5. Click Create.

In this tutorial, you will create a connection to a data source and learn how to use dataset source parameterization in DataLens.

Parameterization will enable you to:

  • Substitute a table in queries.
  • Provide a parameter to the dataset's SQL as part of a query.

We will use a Moscow retail chain's demo sales ClickHouse® database as our data source.

To visualize and explore data, set up DataLens and follow the steps below:

  1. Create a workbook.
  2. Create a connection.
  3. Create a dataset with a table substitution parameter.
  4. Create a chart with a table selection parameter.
  5. Create a dataset with a subquery parameter.
  6. Create a chart with a parameter for selecting a subquery condition.

Getting startedGetting started

To get started with DataLens:

New user
I am already using Yandex Cloud
  1. Log in to your Yandex account. If you do not have an account, create one.
  2. Open the DataLens home page.
  3. Click Open DataLens.
  4. Confirm that you have read the Terms of use and click Log in.
  1. Log in to your Yandex account.

  2. Open the DataLens home page.

  3. Click Open DataLens.

  4. Select one of the options:

    • If you already have an organization, select it from the drop-down menu in the Organizations tab and click DataLens.

      Note

      To activate a DataLens instance, the user must have the admin or owner role. For more information about roles, see Access management in Yandex Identity Hub.

    • If you have a cloud but no organization, click Add new DataLens. In the window that opens, enter your organization's name and description and click Create organization and DataLens. For more information about working with organizations, see Getting started with organizations.

If you have any technical questions about the service, contact Yandex Cloud support. To ask for advice, discuss the solution to your problem or best practices of the service, write to the DataLens chat in Telegram.

Create a workbookCreate a workbook

  1. Go to the DataLens home page.
  2. In the left-hand panel, select Collections and workbooks.
  3. In the top-right corner, click Create → Create workbook.
  4. Enter a name for the workbook: Dataset parametrisation.
  5. Click Create.

Create a connectionCreate a connection

A connection named Sample ClickHouse will be created for database access.

  1. In the top-right corner of the workbook, click Create → Connection.

  2. Under Databases, select the ClickHouse® connection.

    1. In the window that opens, select Specify manually for the connection type and provide the following connection parameters:

      • Host name: rc1a-ckg8nrosr2lim5iz.mdb.yandexcloud.net
      • HTTP interface port: 8443 (default)
      • Username: samples_ro
      • Password: MsgfcjEhJk
    2. Enable the SQL query access level option and select Allow subqueries in datasets and source parameterization.

    3. Click Check connection and make sure you get a green check mark.

    4. Click Create connection.

    5. Enter the connection name: Sample ClickHouse.

    6. Click Create.

      create-connection

Wait for the connection to be saved.

Create a dataset with a table substitution parameterCreate a dataset with a table substitution parameter

Create a dataset based on the Sample ClickHouse connection:

  1. In the top-right corner of the connection page, click Create dataset.

  2. Drag the samples.MS_SalesFacts table to the workspace.

  3. Enable parameterization in the dataset settings. To do this, click at the top and select Enable parameterization.

    image

  4. Save the dataset:

    1. In the top-right corner, click Save.
    2. Enter Dataset with parametrisation for the dataset name and click Create.
  5. Add a parameter with the table name:

    1. Go to the Parameters tab.

    2. Click Add and configure as follows:

      • Name: table_name.
      • Type: String.
      • Default value: MS_SalesFacts.
      • Enable Allow use in source settings and keep the default validation.

      image

      When you click Add, the system will show an error saying that the dataset validation failed. By default, the value of a parameter allowed for use in the source cannot contain _.

      image

  6. Adjust the dataset validation settings to allow the MS_SalesFacts value in the parameter. Proceed as follows:

    1. Click Add and specify Name, Type, and Default value as in the previous step.

    2. Enable Allow use in source settings and select Regular expression for the value validation.

    3. In the field, enter this Python regular expression to enable using uppercase and lowercase letters, digits, and underscores:

      ^[a-zA-Z0-9_]+$
      

    image

    The MS_SalesFacts table name matches this regular expression. When you click Add, the dataset validation will succeed.

  7. Save the dataset.

  8. Change the settings to define the table name with a parameter:

    1. Go to the Sources tab.

    2. In the table list next to MS_SalesFacts go → Change settings.

    3. To the right of the Table name field set to MS_SalesFacts, click and select the table_name parameter. The selected parameter will now define the table name.

      image

    4. Click Apply and save the dataset.

Create a chart with a table selection parameterCreate a chart with a table selection parameter

  1. At the top of your dataset, click Create chart.

  2. Select the Table visualization type.

  3. Create a calculated field:

    1. On the left side of the screen above the list of dataset fields, click and select Field.
    2. Enter the name: Year.
    3. Enter the formula: YEAR([OrderDatetime]).
    4. Click Create.
  4. Add the new field to the chart. To do this, drag the Year field from Dimensions to the Columns section.

  5. Add total sales to the chart. To do this, drag the Sales field from Dimensions to the Columns section and change its aggregation settings:

    1. In the Columns section, click # next to the Sales field.
    2. In the Aggregation field, select Sum and click Apply.

    image

  6. Open the chart inspector and make sure the data comes from the MS_SalesFacts table. To do this, click in the top-right corner of the chart and select Inspector.

    image

  7. Save the chart:

    1. In the top-right corner, click Save.
    2. In the window that opens, enter Table with parametrisation for chart name and click Save.

    image

  8. Change the table name in the relevant chart parameter:

    1. Under Parameters, click the icon next to table_name.

    2. Set the default value to MS_SalesFacts_up.

      image

    3. Click Save. Now, the chart uses data from the MS_SalesFacts_up table.

      image

Create a dataset with a subquery parameterCreate a dataset with a subquery parameter

Create another dataset based on the Sample ClickHouse connection:

  1. Navigate to the Sample ClickHouse connection and click Create dataset in the top-right corner.

  2. Add an SQL query to the source:

    1. At the bottom left under the table list, click → Add.

    2. Open the SQL tab and enter the following query text in the Subquery field:

      SELECT * FROM samples.MS_SalesFacts
      
    3. Click Apply.

  3. Enable parameterization in the dataset settings. To do this, click at the top and select Enable parameterization.

  4. Save the dataset:

    1. In the top-right corner, click Save.
    2. Enter Dataset with parametrisation for sql for the dataset name and click Create.
  5. Add a parameter with the subquery condition:

    1. Go to the Parameters tab.

    2. Click Add and configure as follows:

      • Name: custom_where.

      • Type: String.

      • Default value: 1=1. This condition will always return True.

      • Enable Allow use in source settings and select Regular expression for the value validation. In the field, enter this Python regular expression to allow characters you may need to use when writing SQL queries:

        ^[a-zA-Z0-9а-яАА-ЯёЁ_\s\(\)\.\'\=\-\+\*/\,\<\>!]+$
        

      When you click Add, the dataset validation will succeed.

  6. Save the dataset.

  7. Add a condition to the SQL query text using the parameter:

    1. Go to the Sources tab.

    2. In the table list, click next to SQL and select Change settings.

    3. In the Subquery field, add a WHERE clause to your query:

      SELECT * FROM samples.MS_SalesFacts
      WHERE
      
    4. Under the query input field, click Insert parameter and select custom_where. The selected parameter will now define the SQL query condition.

      SELECT * FROM samples.MS_SalesFacts
      WHERE {{custom_where}}
      

      image

  8. Save the dataset.

Create a chart with a parameter for selecting a subquery conditionCreate a chart with a parameter for selecting a subquery condition

  1. At the top of your dataset, click Create chart.

  2. Select the Indicator visualization type.

  3. Drag the Sales field from Dimensions to the Measure section. This will automatically apply aggregation to this field, making it a measure.

    image

  4. Open the chart inspector and make sure the SQL query uses the 1=1 value of the dataset parameter.

    image

  5. Change the SQL query condition in the parameter:

    1. Under Parameters, click the icon next to table_name.

    2. Set the default value to ProductID IN (SELECT ProductID FROM samples.MS_Products WHERE ProductCategory='Home appliances').

    3. Click Save. This will filter the chart data to only show products in the Home appliances category.

      image

    4. Open the chart inspector and make sure the SQL query now uses the new parameter value.

      image

  6. Save the chart:

    1. In the top-right corner, click Save.
    2. In the window that opens, enter Chart with parametrisation sql for chart name and click Save.

ClickHouse® is a registered trademark of ClickHouse, Inc.

Was the article helpful?

Previous
Using parameters in calculated fields
Next
Examples of creating QL charts
© 2025 Direct Cursus Technology L.L.C.