# Fields and metrics

> With **Data Manager** you can add and edit fields and metrics displayed in your process app. You can also create new fields that derive their values from an expression or calculation based on values from other fields.

With **Data Manager** you can add and edit fields and metrics displayed in your process app. You can also create new fields that derive their values from an expression or calculation based on values from other fields.

## Terminology

* A **Field** is raw data—individual pieces of information tied to each row in your dataset. For example, a field might represent `Price` or `Quantity` for each transaction in a table. Fields describe specific details of each row.
* A **Calculated Field** is a transformation or computation applied to your raw data at the row level. It combines or modifies existing fields using formulas or expressions, creating new values for each row without aggregating data. For example, `Profit` might be a calculated field created by subtracting `Cost` from `Revenue` for each row.
* A **Metric** is a summary or an aggregation of data across multiple rows. Metrics combine data using methods like summing, averaging, or counting to create a high-level indicator of performance. For example, `Total Profit` (sum of all profit) or `Average Quantity Sold` (average of all quantities) are metrics that help provide insights into trends or overall performance. Once created, metrics can be reused across multiple charts and dashboards. Metrics can be used to calculate other metrics.

To summarize: (Calculated) fields provide detailed information row by row, while metrics summarize and aggregate data across multiple rows to help you see the bigger picture.

| **Concept** | **Definition** | **Example** | **Data Level** | **Purpose** |
| --- | --- | --- | --- | --- |
| **Field** | Raw data tied to each row in the dataset. | `Price`, `Quantity`, `Date` | Row-level | Describe specific details of each row. |
| **Calculated field** | A field created from a computation applied to raw data. | `Profit = Revenue - Cost` | Row-level | Combine the values of existing fields. |
| **Metric** | A summary or aggregation of data across multiple rows. | `Total Profit`, `Average Quantity Sold` | Aggregated (multi-row) | Combine data using methods like sum, average, or count. |

## Creating fields and metrics

If you want to add business logic to your process app but the field or metric you want to use is not available by default, you can create new data that you can use in your dashboards. This ensures that your dashboards provide the most valuable insights for stakeholders accross the busssiness.

Follow these steps.

1. In the **Data Manager** panel, select **+New**, then select **New field** or **New metric** from the menu. The **Create field** or **Create metric** panel is displayed.
2. Enter a descriptive name for the new field or metric.
   :::tip
   It is a good practice to refer to the goal of the field or metric, which means an indication of what is computed. For example, `Total_cost`, for a field that which multiplies `Quantity` with `Price_per_item` for each order. (`Total_cost = Quantity * Price_per_item`).
   :::
3. If you create a new field, select the table into which you want to create the new field from the available tables in the **Target table** list.
   :::important
   A value is computed for each row of the selected table. References to fields in other tables are computed relative to the selected table. This means that referring to fields in other tables may yield duplicate results. You can only refer to fields which are reachable from the selected table. For example, you can use fields from the `Cases` table when defining a new field in the `Events` table, but not vice versa. The value of a field in `Cases` table is the same (duplicated) for each row in the `Events` table that belongs to the same case.
   :::
4. Configure the business logic in the **Logic configuration** editor using the available logic blocks.
   1. Add the logic block for the operations.
   2. Add the fields and constants to define the operations.
      :::tip
      You can select the **Preview** button to view a sample of the values resulting from the calculation.
      :::
5. Select **Save**.
   :::note
   The **Save** button is only enabled if the logic configuration is complete and correct.
   :::

The field or metric is added to the list of fields and metric in the **Data Manager**.

:::tip
You can also create a new field for a specific table in the **Data manager**. Follow these steps to create a new field for a specific table.
1. In Data manager, locate the table into which you want to create the field.
2. Select the ![Menu](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-image-129960-0d9a692d-b3b8346a.webp) icon to open the menu and select + **Create new field**.
The **Create data** window is displayed and the table is selected in the **Tables** field.
:::

### Adding logic blocks to the canvas

You can easily drag and drop logic blocks onto the Logic configuration canvas to build an expression.

When you create a logic flow or a calculation, the inputs and outputs of each logic block must match up correctly in terms of data kind. The expression is validated, and feedback is displayed on the logic block to help you to troubleshoot and correct the calculations as you go.

:::note
You can only save the logic configuration if it has no errors.
:::

### Drafts

#### Saving a logic block or configuration as a draft

You can save a logic block or configuration and reuse it later.

Follow these steps.

1. Select the logic block you want to save as a draft, and drag it to the **Logic blocks** panel. The **Logic blocks** panels shows a **Add block to draft** area.
2. Drop the logic block on the **Add block to draft** area.

The logic block is removed from the canvas and saved as a draft on the **Draft** tab.

#### Using a draft

Follow these steps to use a draft in your configuration.

1. Go to the **Draft** tab and locate the logic block you want to use.
2. Drag and drop the logic block to the desired location in your **Logic configuration**.
   :::note
   The draft is no longer available on the **Draft** tab.
   :::

### Removing a logic block

Follow these steps to remove a logic block.

1. Select the logic block you do not want to use anymore, and drag it to the **Logic blocks** panel. The **Logic blocks** panels shows a **Delete block** area.
2. Drop the logic block on the **Delete block** area.

The logic block is removed from the canvas.

## Editing fields and metrics

### Editing field properties

This enables you to customize the dashboards by adapting them to the terminology used in your organization.Follow these steps to edit the properties of a field.

1. Select the field for which you want to edit the properties. The **Edit field** dialog is displayed.
2. Edit the **Field name** as desired.
3. Select **Save**.

   ![Edit field dialog](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-edit-field-dialog-346588-0f03f951-48e75c5b.webp)

#### Changing the field name

You can change the name of the fields. This enables you to customize the dashboards by adapting them to the terminology used in your organization.

#### Changing the field type

The field type indicates the kind of data that the field is intended to hold and therefore determines how the field can be used. There might be instances where the field **Type** does not align with the kind of data of the source field in your dataset. For example, you may upload data of an *integer* to a field that was previously uploaded with *text*. Such instances will be indicated in the **Fields** list in the **Data manager**.

   ![Field does not align with the data in the source](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-field-does-not-align-with-the-data-in-the-source-366724-3ccb4682-3bdcba84.webp)

For these fields, you can change the **Type** of the field.

:::note
You can only select a new **Type** based on the data kind of the source field that is uploaded. For example, if the field in the dataset is an *integer*, you can change the field to *number***,** and if the field in the dataset is of *text*, you can change the field to *nominal* or *ordinal*.
:::
:::note
You can only change the **Type** of a field that is not used in dashboards. In case the field is actually used in dashboards:
1. Remove the field from the chart or charts.
2. Edit the **Type** of the field.
3. Add the field back on the chart or charts.
:::

### Editing custom fields

You can only edit the expression for custom fields you created from the **Data Manager**.

Follow these steps to edit a custom field.

1. In the **Data Manager** panel, locate the field you want to edit and select the Edit icon.![Edit icon](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-rename-section-icon-289309-c8e41793-c6525877.webp)The logic configuration of the field expression is displayed.
2. Edit the expression as desired and select **Save**.

The logic configuration editor is closed and you return to the dashboard editor.

### Editing metric properties

Follow these steps to edit the properties of a metric.

1. In the **Data Manager** panel, locate the metric for which you want to edit the properties and select the Edit icon.![Edit icon](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-rename-section-icon-289309-c8e41793-c6525877.webp)The **Metric details** panel is displayed.
2. Edit the **Metric properties** as desired.
3. Select **Save**.

The following table describes the available metric properties.

| Element | Description |
| --- | --- |
| Metric name | The display name of the metric. |

### Editing metrics

Follow these steps to edit a metric.

1. In the **Data Manager** panel, locate the metric you want to edit and select the Edit icon.![Edit icon](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-rename-section-icon-289309-c8e41793-c6525877.webp)The logic configuration of the metric expression is displayed.
2. Edit the expression as desired and select **Save**.

The logic configuration editor is closed and you return to the dashboard editor.

## Hiding and showing fields

With **Data Manager** you can hide fields that are available in your dataset but not used in your process app. A field that is set to hidden in **Data Manager**, will not be visible in selectors when editing dashboards using the dashboard editor. This is useful when you do not want to use these fields in a visualization, but do want to use them to compute metrics.

:::note
You can not hide a field that is used on a dashboard.
:::

Follow these steps to hide a field.

1. Locate the field you want to hide.
2. Select the **Hide field in app** icon ![Hide field in app](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-hide-field-in-app-461012-65661b27-39da332a.webp) icon The field is set to hidden and the icon is changed to the **Show field in app** icon ![Show field in app icon](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-show-field-in-app-icon-461016-e11cae31-91a853ea.webp). If you select the icon, the field becomes visible again.

## Context metrics

You can add context metrics to provide a better understanding of the main metric displayed on the chart. Context metrics are displayed as tooltips on charts.

The following illustration shows a chart with the main metric **Average amount** and **Number of cases** as a context metric.

   ![Context metric](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-example-context-metric-423994-c45f0401-08bd4149.webp)

Depending on the calculation of the main metric, different contexts may be useful to explain the main metric. For example, if the main metric is defined as `Average amount`, useful context is `Number of objects` for which the average amount is calculated. This also applies when you main metric is defined as `Total amount`. In this case, also `Number of objects` for which the sum is calculated is a useful context.

When your main metric is defined as a percentage, for example `Cases with tag (%)`, useful contexts can be `Number of objects with tag` and `Total number of objects`.

The following table shows some examples of main metrics with relevant context metrics.

|  | Main metric | Context metric 1 | Context metric 2 |
| --- | --- | --- | --- |
| **Count** | Number of objects  `112` | - | - |
| **Average** | Average amount  `€ 61,43` | Objects  `112` | - |
| **Sum** | Total amount  `€ 123.555,00` | Objects  `112` | - |
| **Percentage** | Objects with tag %​  `60%` | Objects with tag  `600` | Total objects  `1000` |

## Deleting fields

To keep your data clean, you can delete fields that are not used anymore. Follow these steps to delete a field.

:::important
You can only delete empty fields.
:::

1. In the **Data Manager** panel, locate the field you want to delete.
2. Open the actions menu for the field and select **Delete field**.

The field is removed without any notification.

## Deleting metrics

To keep your process app clean, you can delete metrics that are not used anymore. Follow these steps to delete a metric.

1. In the **Data Manager** panel, locate the metric you want to delete.
2. Open the actions menu for the metric and select **Delete metric**. A confirmation message is displayed.
3. Select **Delete**.

   ![Delete metric confirmation message](https://dev-assets.cms.uipath.com/assets/images/process-mining/process-mining-delete-metric-confirmation-message-15505-b8ae1494-fe36e9b5.webp)

   :::note
   You can only delete user-created metrics. Metrics that are used in charts can not be deleted.
   :::

### Viewing metric references

If you want to delete a metric that is used in charts, you must first delete the metric references. When you hover over the **Delete metric** icon, a popup is displayed indicating which dashboards and charts the metric is used in.

## Duplicating metrics and fields

Duplicating allows you to re-use a metric or calculated field and make modifications without the need to create a complete new metric or field.

Dupicating a metric or field creates a copy of the original directly underneath the duplicated metric or field.

Follow these steps to duplicate of a metric or field.

1. In the **Data Manager** panel, locate the metric or field you want to duplicate.
2. Open the actions menu and select **Duplicate metric**, or **Duplicate field**.
