---
schema_version: "1"
id: dc8eba7be3d8f0056a2e96c001ff69ee1144c02eceeb7205162e6ba7364a7203
title: Use Formulas in Omnistudio Data Mappers
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_use_formulas_in_dataraptors_47540.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_use_formulas_in_dataraptors_47540.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: c1a7ebdcabf687009ef007c85bc23a0acc8b6ecda931b01f82090a74da6380e2
description: To add data to the output of a Data Mapper, define formulas. Several types of Data Mappers (Extract, Transform, and Load) support formulas. When you define a formula, you map its output to the output JSON (for extracts and transforms) or Salesforce object field (for loads).
products:
  - Omnistudio
release: "264"
---
# Use Formulas in Omnistudio Data Mappers

To add data to the output of a Data Mapper, define _formulas_. Several types of Data Mappers (Extract, Transform, and Load) support formulas. When you define a formula, you map its output to the output JSON (for extracts and transforms) or Salesforce object field (for loads).

For details about the operators and functions that you can use in formulas, see [Omnistudio Formulas and Functions](https://help.salesforce.com/s/articleView?id=xcloud.os_omnistudio_formulas_and_functions.htm&release=264.0.0&type=5 "Use operators and functions to create formulas for Omnistudio Data Mappers and Integration Procedures.").

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio-264-0-0-production-enus/f526eaa8-ae05-487a-8944-4bb99b0b78ac/images/icon_note.png)

Note

If a variable name contains spaces or non-alphanumeric characters, enclose the variable name in double quotes and precede it with `var:` in formulas. For example, if the JSON node name is `Primary Guardian`, specify it in formulas as `var:"Primary Guardian"`.

If the name of a custom field includes special characters, sometimes you can't reference the field in a formula.

In the Omnistudio standard runtime, entering the incorrect query formula for Data Mappers returns null but doesn't display error logs. If you get a null response from a query, update the query.

1. In the Data Mapper Interface page, go to the **Formulas** tab.
2. Click **Add Formula**. An empty formula is added to the list.
3. In the **Formula** field, specify the desired logic. For example, to determine the total price of the purchase items by a customer, enter a formula such as:
    
    `SUM(Products:Price)`
    
    You can also use relationship notation in formulas to reference fields in a parent object. See [Relationship Notation versus Multiple Extract Steps](https://help.salesforce.com/s/articleView?id=xcloud.os_relationship_notation_versus_multiple_extract_steps_45995.htm&release=264.0.0&type=5 "Using relationship notation improves the performance of Omnistudio Data Mappers that retrieve data from a parent of the primary object. Use this notation in the Extract JSON Paths for the parent object's fields instead of adding a second object in the Data Mapper's Extract tab.").
4. In the **Formula Result Path** field, specify a JSON node in which to store the formula result.
5. Map the result to the final output.
    - For an Extract Data Mapper, on the **Output** tab, map the formula result to the output structure. Use a colon (:) to delimit levels in the input and output paths in mappings.
    - For a Transform Data Mapper, on the **Transforms** tab, map the formula result to the output structure. Use a colon (:) to delimit levels in the input and output paths in mappings.
    - For a Load Data Mapper, for each sObject that you want to update, on the **Fields** tab, map the formula result to the field that you want to update.
6. Load: For each sObject that you want to update, go to its **Fields** tab and map the formula result to the specific field that you want to update.

## Create an Omnistudio Data Mapper Example with a Formula

The following example accepts a list of prices and uses a formula to compute the total price.

To create this Data Mapper Transform, perform these steps:

1. Go the Omnistudio Data Mapper Designer tab and click **New**. The Create dialog is displayed.
2. Specify a name for the Data Mapper and configure its settings as follows:
    - **Interface Type**: Transform
    - **Input Type**: JSON
    - **Output Type**: JSON
3. Click **Save**. The Data Mapper Interface page is displayed.
4. Go to the Formulas tab and click **Add Formula**.
5. In the **Formula** field, enter SUM(Products:Price).
6. In the **Formula Result Path** field, enter TotalPrice.
7. On the Transforms tab, expand the **Input JSON** pane and paste this JSON structure into it:
    
    ```
    {
        "CustomerName": "Bob Smith",
        "Products": [
            {
                "Name": "iPhone",
                "Price": 600
            },
            {
                "Name": "iPhone Case",
                "Price": 30
            },
            {
                "Name": "Ear Buds",
                "Price": 200
            }
        ]
    }
    ```
8. Expand the **Expected JSON Output** pane and paste this JSON structure into it:
    
    ```
    {
        "CustomerName": "Bob Smith",
        "TotalPrice": 830,
        "Products": [
            {
                "Name": "iPhone",
                "Price": 600
            },
            {
                "Name": "iPhone Case",
                "Price": 30
            },
            {
                "Name": "Ear Buds",
                "Price": 200
            }
        ]
    }
    ```
9. Click **Quick Match**. In the Quick Match window, click **Auto Match**, then click **Save**.
10. On the Preview tab, click **Execute**.
    
    If you have built the example correctly, the JSON structure in the Response pane matches the Expected JSON Output except for the order of the top-level nodes.
11. In the Input pane, change one or more of the prices, then click **Execute** again.
    
    Note how the `TotalPrice` value changes.