Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Solutions
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex DataLens
  • Getting started
  • Use cases
    • All use cases
    • Visualizing data from a CSV file
    • Visualizing data from a ClickHouse database
    • Visualizing data from Yandex.Metriсa
    • Visualizing data from Yandex.Metrica Logs API
    • Publishing a chart with a map from a CSV file to DataLens Public
    • Visualizing data from AppMetrica
    • Visualizing geodata from a CSV file
  • Step-by-step instructions
    • All instructions
    • Working with connections
      • Creating a ClickHouse connection
      • Creating a connection to a CSV file
      • Creating a MySQL connection
      • Creating a PostgreSQL connection
      • Creating an MS SQL Server connection
      • Creating an Oracle Database connection
      • Creating a Yandex.Metrica API connection
      • Creating a Yandex.Metrica Logs API connection
      • Creating an AppMetrica connection
      • Managing connection access
    • Working with datasets
      • Create dataset
      • Creating a data field
      • Creating a calculated data field
      • Updating fields in datasets
      • Dataset materialization
      • Managing dataset access
      • Managing access to data rows
    • Working with charts
      • Creating a line chart
      • Creating an area chart
      • Creating a pie chart
      • Creating a column chart
      • Creating a bar chart
      • Creating a map
      • Creating a table
      • Creating a pivot table
      • Publishing a chart
      • Managing chart access
    • Working with dashboards
      • Creating dashboards
      • Adding charts to dashboards
      • Adding selectors to dashboards
      • Publishing dashboards
      • Managing dashboard access
    • Working with permissions
      • Granting permissions
      • Deleting permissions
      • Request permissions
  • Concepts
    • Overview
    • Connections
    • Data types
    • Datasets
      • Overview
      • Data model
      • Dataset settings
    • Charts
    • Dashboards
    • Using Markdown in DataLens
    • DataLens Public
    • Calculated fields
    • Marketplace
    • Backups in DataLens
    • Quotas and limits
  • Access management
    • Managing access to DataLens
    • Managing access at the data row level
  • Pricing policy
    • Current pricing policy
    • Archive
      • Policy before March 1, 2021
  • Function reference
    • All Functions
    • Aggregate functions
      • Overview
      • ALL_CONCAT
      • ANY
      • ARG_MAX
      • ARG_MIN
      • AVG
      • AVG_IF
      • COUNT
      • COUNTD
      • COUNTD_APPROX
      • COUNTD_IF
      • COUNT_IF
      • MAX
      • MEDIAN
      • MIN
      • QUANTILE
      • QUANTILE_APPROX
      • STDEV
      • STDEVP
      • SUM
      • SUM_IF
      • TOP_CONCAT
      • VAR
      • VARP
    • Date/Time functions
      • Overview
      • DATEADD
      • DATEPART
      • DATETRUNC
      • DAY
      • DAYOFWEEK
      • HOUR
      • MINUTE
      • MONTH
      • NOW
      • QUARTER
      • SECOND
      • TODAY
      • WEEK
      • YEAR
    • Geographical functions
      • Overview
      • GEOCODE
      • GEOINFO
      • TOPONYM_TO_GEOPOINT
      • TOPONYM_TO_GEOPOLYGON
    • Logical functions
      • Overview
      • CASE
      • IF
      • IFNULL
      • ISNULL
      • ZN
    • Text markup functions
      • Overview
      • BOLD
      • ITALIC
      • MARKUP
      • URL
    • Mathematical functions
      • Overview
      • ABS
      • ACOS
      • ASIN
      • ATAN
      • ATAN2
      • CEILING
      • COS
      • COT
      • DEGREES
      • DIV
      • EXP
      • FLOOR
      • GREATEST
      • LEAST
      • LN
      • LOG
      • LOG10
      • PI
      • POWER
      • RADIANS
      • ROUND
      • SIGN
      • SIN
      • SQRT
      • SQUARE
      • TAN
    • Operators
      • Overview
      • AND
      • Addition and concatenation (+)
      • BETWEEN
      • Comparison
      • Division (/)
      • IN
      • IS FALSE
      • IS TRUE
      • LIKE
      • Modulo (%)
      • Multiplication (*)
      • NOT
      • Negation (-)
      • OR
      • Power (^)
      • Subtraction (-)
    • String functions
      • Overview
      • ASCII
      • CHAR
      • CONCAT
      • CONTAINS
      • ENDSWITH
      • FIND
      • ICONTAINS
      • IENDSWITH
      • ISTARTSWITH
      • LEFT
      • LEN
      • LOWER
      • LTRIM
      • REGEXP_EXTRACT
      • REGEXP_EXTRACT_NTH
      • REGEXP_MATCH
      • REGEXP_REPLACE
      • REPLACE
      • RIGHT
      • RTRIM
      • SPACE
      • SPLIT
      • STARTSWITH
      • SUBSTR
      • TRIM
      • UPPER
      • UTF8
    • Time series functions
      • Overview
      • AGO
      • AT_DATE
    • Type conversion functions
      • Overview
      • BOOL
      • DATE
      • DATETIME
      • DATETIME_PARSE
      • DATE_PARSE
      • DB_CAST
      • FLOAT
      • GEOPOINT
      • GEOPOLYGON
      • INT
      • STR
    • Window functions
      • Overview
      • AVG
      • AVG_IF
      • COUNT
      • COUNT_IF
      • FIRST
      • LAG
      • LAST
      • MAVG
      • MAX
      • MCOUNT
      • MIN
      • MMAX
      • MMIN
      • MSUM
      • RANK
      • RANK_DENSE
      • RANK_PERCENTILE
      • RANK_UNIQUE
      • RAVG
      • RCOUNT
      • RMAX
      • RMIN
      • RSUM
      • SUM
      • SUM_IF
    • Function Availability
  • Questions and answers
  1. Concepts
  2. Calculated fields

Calculated fields

  • Calculated fields in datasets
  • Calculated fields in charts
  • Functions
    • Notation format
    • Examples of using functions
  • How to create a calculated field

A calculated field is an additional data field with values calculated using a formula.
You can use calculated fields to create new dimensions and measures.
The data source remains unchanged.

To write formulas, you can use existing dataset fields, constants, and functions.

You can create calculated fields in the dataset or wizard interface:

  • Calculated fields from a dataset are available in all charts above this dataset.
  • Calculated fields from a wizard are only available for the saved chart.

Calculated fields in datasets

You can add new fields to the list of dataset fields.

When creating a formula, you can use any dataset field, including the calculated fields that you created earlier.

After creating a calculated field and saving the dataset, the field becomes available to all the charts and dashboard selectors based on that dataset.
To prevent fields from being displayed in the wizard, enable the Don't display option when creating them.

Calculated fields are marked with .

Calculated fields in charts

You can add new fields when creating and editing charts in the wizard:

  • In the list of fields from a dataset.
  • In the visualization section.

When creating a formula, you can use any dataset field, including the calculated fields that you created earlier.

If a field is created in a chart, it isn't available to dashboard selectors and other charts.

Calculated fields are marked with .

Warning

In multi-dataset charts, calculated fields are not applicable to fields from multiple datasets.

Functions

Functions are the main components used for creating formulas. You can use them to perform various operations on data fields.

The list of available functions depends on the data source. For more information, see Function Availability.

Warning

Avoid calculation loops: in a formula, you can't use a field that uses the same formula to calculate its own value.

Notation format

Write formulas that meet the following requirements:

  1. Function arguments are specified in parentheses. For example, YEAR([DATE1]). Multiple arguments are separated by a comma.
  2. Field names are given in square brackets. For example, [CustomerID].
  3. Make sure to enter the values of fields and constants in a valid format. For example, use a dot as a decimal separator: 0.123.

Note

The function syntax is case-insensitive: count and COUNT perform the same operation.

For reference information about the format, types of accepted arguments, and returned function values, see the formula editor interface.
To do this, click Reference in the add field interface.

Examples of using functions

Concatenation of string values

[City] + " " + "city"

Concatenates the following three string values: the [City] field value, the space, and the city text. For concatenation, you can also use the CONCAT string function.

Full description of the addition operator (+).

Truncation of dates

DATETRUNC(#2018-07-12#, "year", 5) = #2015-01-01#

Truncates the date 2018-07-12 to a year that is a multiple of 5.

Full description of the date truncation function DATETRUNC.

Type conversion

FLOAT([StringWithNumbers])

Converts the StringWithNumbers string field to a fractional number.

Full description of the FLOAT conversion function.

How to create a calculated field

You can create calculated fields in the dataset or wizard interface.

Datasets
Wizard
  1. Open the dataset.
  2. In the upper-right corner, click Add field.
  3. Enter a name for the field.
  4. Select Formula as the data source for the field.
  5. Set the formula using data source functions.
  6. Click Create. The field appears in the dataset.
  1. Open the wizard.
  2. Select the dataset to create a chart in.
  3. To the left of the screen, click above the list of dataset fields.
  4. Enter the required formula.
  5. Click Create. The field appears in the list of fields. You can use it as your chart's data source.

See also

  • Creating a field
  • Managing access to data rows in a dataset
In this article:
  • Calculated fields in datasets
  • Calculated fields in charts
  • Functions
  • Notation format
  • Examples of using functions
  • How to create a calculated field
Language / Region
Careers
Privacy policy
Terms of use
Brandbook
© 2021 Yandex.Cloud LLC