---
metadata:
  - name: generator
    content: Diplodoc Platform v5.63.0
alternate:
  - en/concepts/calculations/
  - ru/concepts/calculations/
  - href: en/concepts/calculations/index.md
    type: text/markdown
    title: Markdown version
csp:
  - script-src:
      - https://mc.yandex.ru
    img-src:
      - https://mc.yandex.ru
    connect-src:
      - https://mc.yandex.ru
      - wss://mc.yandex.ru
    child-src:
      - 'blob:'
      - https://mc.yandex.ru
    frame-src:
      - 'blob:'
      - https://mc.yandex.ru
    frame-ancestors:
      - 'blob:'
      - https://mc.yandex.ru
canonical: en/concepts/calculations/index.html
title: Calculated fields in DataLens On-premises
description: >-
  In DataLens On-premises, a calculated field is an additional data field whose
  values are calculated using a formula.
vcsPath: en/concepts/calculations/index.md
---

# Calculated fields in DataLens On-premises

A calculated field is an additional [data field](../../dataset/index.md#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 the existing dataset fields, [parameters](../parameters.md), constants, and [functions](#functions).

You can [create](#how-to-create-calculated-field) calculated fields in the dataset or wizard interface:

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

Calculated fields are marked with <!-- diplodoc:svg ![image](../../_assets/console-icons/function.svg) --><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><g clip-path="url(#svg-r8z6at6q__a)"><path fill="currentColor" fill-rule="evenodd" d="M4.312 4.29a.764.764 0 0 1 1.103-.62.75.75 0 1 0 .67-1.34 2.264 2.264 0 0 0-3.268 1.836L2.706 5.5H1.75a.75.75 0 0 0 0 1.5h.83l-.392 4.71a.764.764 0 0 1-1.103.62.75.75 0 0 0-.67 1.34 2.264 2.264 0 0 0 3.268-1.836L4.086 7H5.25a.75.75 0 1 0 0-1.5H4.21zm6.014 2.23a.75.75 0 0 0-1.152.96l.85 1.02-.85 1.02a.75.75 0 0 0 1.152.96L11 9.672l.674.808a.75.75 0 0 0 1.152-.96l-.85-1.02.85-1.02a.75.75 0 0 0-1.152-.96L11 7.328zM8.02 4.55a.75.75 0 0 1 .43.969l-.145.378a7.25 7.25 0 0 0 0 5.205l.145.378a.75.75 0 0 1-1.4.539l-.145-.378a8.75 8.75 0 0 1 0-6.282l.145-.378a.75.75 0 0 1 .97-.431m5.961 0a.75.75 0 0 1 .97.43l.145.379a8.75 8.75 0 0 1 0 6.282l-.146.378a.75.75 0 1 1-1.4-.538l.146-.379a7.25 7.25 0 0 0 0-5.205l-.146-.378a.75.75 0 0 1 .431-.97" clip-rule="evenodd"/></g><defs><clipPath id="svg-r8z6at6q__a"><path fill="currentColor" d="M0 0h16v16H0z"/></clipPath></defs></svg>.

## Calculated fields in datasets {#dataset}

You can add new fields to a dataset field list.

When creating a formula, you can use any dataset field, including the calculated fields you previously created. In a formula, you can also use parameters created at the dataset level.

After creating a calculated field and saving the dataset, the field becomes available to all charts and dashboard [selectors](../../dashboard/selector.md) based on that dataset.

To hide fields in the wizard, enable the **Do not display in wizard** option when creating them.

## Calculated fields in charts {#chart}

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 you previously created. In a formula, you can also use the parameters of the chart or dataset based on which the chart is created.

If a field is created in a chart, it will not be available to dashboard selectors and other charts.

{% note warning %}

In [multi-dataset charts](../chart/index.md#multi-dataset-charts), calculated fields are not applicable to fields from multiple datasets.

{% endnote %}

## Functions {#functions}

Functions are the principal 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](../../function-ref/availability.md).

{% note warning %}

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

{% endnote %}

### Notation format {#entry-format}

Write formulas according to the following requirements:

1. Specify function arguments in parentheses, e.g., `YEAR([DATE1])`. Separate multiple arguments with commas.
1. Specify field names in square brackets, e.g., `[CustomerID]`.
1. Make sure to enter the values of fields and constants in a valid [format](../../dataset/data-types.md). For example, use a period as a decimal separator: `0.123`.

{% note info %}

* Field name syntax is case-sensitive. For example, if the formula uses `[NAME]`, while the dataset contains only `[Name]`, the formula field will be highlighted in red.
* Function syntax is not case-sensitive. For example, `count` and `COUNT` will perform the same operation.

{% endnote %}

For more information on format, types of accepted arguments, and returned function values, use the **Reference** button when adding a field in the formula editor interface.

## How to create a calculated field {#how-to-create-calculated-field}

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

{% list tabs %}

- Dataset

  <!-- source: en/_includes/datalens/operations/datalens-create-calculated-field-in-dataset.md -->
  1. In the left-hand panel, click <!-- diplodoc:svg ![image](../../_assets/console-icons/circles-intersection.svg) --><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M6.576 11.854a4 4 0 1 1 0-7.707A5.48 5.48 0 0 0 5 8c0 1.5.601 2.861 1.576 3.854M8 12.9a5.5 5.5 0 1 1 0-9.8 5.5 5.5 0 1 1 0 9.8m1.424-8.754A4.003 4.003 0 0 1 14.5 8a4 4 0 0 1-5.076 3.854A5.48 5.48 0 0 0 11 8c0-1.5-.601-2.861-1.576-3.854M8 4.877C8.914 5.61 9.5 6.737 9.5 8s-.586 2.39-1.5 3.123A4 4 0 0 1 6.5 8c0-1.263.586-2.39 1.5-3.123" clip-rule="evenodd"/></svg> **Datasets** and select the dataset you need. If you do not have a dataset, [create one](../../dataset/create-dataset.md#create).
  1. In the top-right corner, click **<!-- diplodoc:svg ![image](../../_assets/console-icons/plus.svg) --><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M8 1.75a.75.75 0 0 1 .75.75v4.75h4.75a.75.75 0 0 1 0 1.5H8.75v4.75a.75.75 0 0 1-1.5 0V8.75H2.5a.75.75 0 0 1 0-1.5h4.75V2.5A.75.75 0 0 1 8 1.75" clip-rule="evenodd"/></svg> Add field**.
  1. Enter a name for the field.
  1. Select **Formula** as the data source for the field.
  1. Add the formula using [data source functions](../../function-ref/all.md).
  1. Click **Create**. The field will appear in the dataset.
  <!-- endsource: en/_includes/datalens/operations/datalens-create-calculated-field-in-dataset.md -->

  ![dataset-calculated-field](../../_assets/datalens/concepts/dataset-calculated-field.png)

- Wizard
  

  1. In the left-hand panel, click <!-- diplodoc:svg ![image](../../_assets/console-icons/chart-column.svg) --><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><g clip-path="url(#svg-lnax3njx__a)"><path fill="currentColor" fill-rule="evenodd" d="M11.5 3.5h2a.5.5 0 0 1 .5.5v8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1-.5-.5V4a.5.5 0 0 1 .5-.5m-2.5 9a.5.5 0 0 0 .5-.5V7a.5.5 0 0 0-.5-.5H7a.5.5 0 0 0-.5.5v5a.5.5 0 0 0 .5.5zm-4.5 0A.5.5 0 0 0 5 12v-2a.5.5 0 0 0-.5-.5h-2a.5.5 0 0 0-.5.5v2a.5.5 0 0 0 .5.5zm-1 1.5h-1a2 2 0 0 1-2-2v-2a2 2 0 0 1 2-2h2q.26 0 .5.063V7a2 2 0 0 1 2-2h2q.26 0 .5.063V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2z" clip-rule="evenodd"/></g><defs><clipPath id="svg-lnax3njx__a"><path fill="currentColor" d="M0 0h16v16H0z"/></clipPath></defs></svg> **Charts** and select the chart created in the [wizard](https://datalens.ru/wizard).
  1. On the left side of the screen above the list of dataset fields, click <!-- diplodoc:svg ![image](../../_assets/console-icons/plus.svg) --><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M8 1.75a.75.75 0 0 1 .75.75v4.75h4.75a.75.75 0 0 1 0 1.5H8.75v4.75a.75.75 0 0 1-1.5 0V8.75H2.5a.75.75 0 0 1 0-1.5h4.75V2.5A.75.75 0 0 1 8 1.75" clip-rule="evenodd"/></svg> and select **Field**.
  1. Enter a name for the field.
  1. Enter the required formula.
  1. Click **Create**. The field will appear in the list on the left. You can use it in a chart.

  ![chart-calculated-field](../../_assets/datalens/concepts/chart-calculated-field.png)

  You can also [duplicate](../../dataset/create-dataset.md#duplicate-fields) any dataset field, including the calculated field you previously created.

{% endlist %}

#### Useful links {#see-also}

* [Creating fields](../../dataset/create-dataset.md#create-fields)
