---
schema_version: "1"
id: e1d81d397c4e68f8eb1bcecd3fae878d77d7fdde8efaa9f525b80212ffb4e825
title: computeRelative Parameters
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/analytics/264-0-0/bi_integrate_computerelative_transformation_operation.md
canonical_url: https://help.salesforce.com/s/articleView?id=analytics.bi_integrate_computerelative_transformation_operation.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 75ee5acb98a4ac0d3d9c2edac6da447271aff2979d8683071bc9f45740a74673
description: When you define a computeRelative transformation, you set the action attribute to computeRelative. You also specify the parameters for the input source, partition-by field, sort field, and derived field definitions.
products:
  - CRM Analytics
  - Cross Cloud
release: "264"
---
# computeRelative Parameters

When you define a computeRelative transformation, you set the action attribute to `computeRelative`. You also specify the parameters for the input source, partition-by field, sort field, and derived field definitions.

## Parameters

You can specify parameters in the following sections of the computeRelative node.

The following table describes the parameters in the `parameters` section.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:20%">
          <col style="width:20%">
          <col style="width:60%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41907e53">Parameter</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41907e56">Required?</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41907e59">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e53 ">source</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e56 ">Yes</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e59 ">Node in the dataflow definition file that identifies the input source for this
              transformation.</td>

          </tr>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e53 ">partitionBy</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e56 ">Yes</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e59 ">API name of the field used to partition the records in the dataset. Specify one
              partition-by field only.</td>

          </tr>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e53 ">orderBy</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e56 ">Yes</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e59 ">
              <p>Field used to sort the records within each partition and the sort order:
                ascending (<code>asc</code>) or descending (<code>desc</code>). Specify one sort field only.</p>
              <div>
                <p>Example:
                </p>
                <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"orderBy": [
    {                
        "name":"CreatedDate", 
        "direction":"asc"
     }
]</code></pre>
              </div>
            </td>

          </tr>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e53 ">computedFields</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e56 ">Yes</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e59 ">
              <p>A list of definitions for derived fields. Derived fields can be based on a
                source field or on a SAQL expression.</p>
              <div>
                <p>Example showing derived fields based on a
                  source field and on a SAQL expression:
                </p>
                <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"computedFields": [
                {
          "name": "PreviousAmount",
          "label": "Previous Amount",
          "description": "Previous amount of opportunity",
          "expression": {
            "sourceField": "Amount",
            "offset": "previous()",
            "default": "null"
          }
        },
        {
          "name": "AmountChange",
          "label": "Amount % Change",
          "description": "Percentage change from previous amount",
          "expression": {
            "saqlExpression": "(current(Amount)-previous(Amount))/previous(Amount)*100",
            "type": "Numeric",
            "scale": 2,
            "default": "null"
          }
        }
      ]</code></pre>
              </div>
            </td>

          </tr>
        </tbody>
      </table>

## computedFields

The following table describes the attributes in the `computedFields` section.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:20%">
          <col style="width:20%">
          <col style="width:60%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41907e157">Parameter</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41907e160">Required?</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41907e163">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e157 ">name</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e160 ">Yes</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e163 ">API name of the derived field to add to the dataset. The name must be unique in
              the dataset. If the name is not unique, the dataflow fails to run.</td>

          </tr>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e157 ">label</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e160 ">No</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e163 ">The display name of the derived field that appears in the CRM Analytics user
              interface. Can be up to 255 characters. Defaults to the API name if not
              specified.</td>

          </tr>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e157 ">description</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e160 ">No</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e163 ">Description of the derived field for information only.</td>

          </tr>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e157 ">expression</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e160 ">Yes</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e163 ">
              <p>Expression attributes used to calculate the value for the derived field. The
                expression can be based on input fields or other derived fields in the
                transformation.</p>
              <div>
                <p>Example: </p>
                <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"expression": {
    "sourceField": "CloseDate",
    "offset": "previous()",
    "default": "01-01-1970"</code></pre>
              </div>
            </td>

          </tr>
        </tbody>
      </table>

## expression

The following table describes the attributes in the `expression` section when creating a derived field based on a source field.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:20%">
          <col style="width:20%">
          <col style="width:60%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41907e251">Parameter</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41907e254">Required?</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41907e257">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e251 ">sourceField</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e254 ">Yes</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e257 ">API name of the input field from the source node that’s used in the
              expression.</td>

          </tr>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e251 ">
              <span id="bi_integrate_computeRelative_transformation_operation__type_fieldattribute"><a name="bi_integrate_computeRelative_transformation_operation__type_fieldattribute"><!-- --></a>offset</span>
            </td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e254 ">Yes</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e257 ">
              <p>The function used in the expression. You can use the following functions:</p>
              <dl>
                <dt style="font-weight:bold;padding-top:.25rem;"><code>current()</code></dt>
                <dd style="padding-left:1.5rem;padding-bottom:.5rem;">Gets the value from the current record.</dd>
                <dd style="padding-left:1.5rem;padding-bottom:.5rem;">Example:
                  <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"offset": "current()"</code></pre>
                </dd>
                <dt style="font-weight:bold;padding-top:.25rem;"><code>first()</code></dt>
                <dd style="padding-left:1.5rem;padding-bottom:.5rem;">Gets the value from the first record in the partition, like the first
                  CreateDate for an opportunity.</dd>
                <dd style="padding-left:1.5rem;padding-bottom:.5rem;">Example:
                  <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"offset": "first()"</code></pre>
                </dd>
                <dt style="font-weight:bold;padding-top:.25rem;"><code>next()</code></dt>
                <dd style="padding-left:1.5rem;padding-bottom:.5rem;">
                  <p style="margin-bottom:0;">Gets the value from the next record.</p>
                </dd>
                <dd style="padding-left:1.5rem;padding-bottom:.5rem;">Example:
                  <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"offset": "next()"</code></pre>
                </dd>
                <dt style="font-weight:bold;padding-top:.25rem;"><code>previous()</code></dt>
                <dd style="padding-left:1.5rem;padding-bottom:.5rem;">Gets the value from the previous record.</dd>
                <dd style="padding-left:1.5rem;padding-bottom:.5rem;">Example:
                  <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"offset": "previous()"</code></pre>
                </dd>
              </dl>
              <p>Derived fields are computed in the order that they’re defined. The
                calculation of a derived field can be based on the value from another derived
                field as long as it has already been defined. For example, <code>next()</code> can’t access the value of a derived field in
                the next row. </p>
              <p style="margin-bottom:0;">To get the correct results when using the <code>previous()</code> and <code>next()</code> functions, the computeRelative transformation requires you to
                sort the records.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e251 ">default</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e254 ">Yes (for numeric fields only)</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e257 ">
              <p>The default value if one can’t be calculated. For example, you can specify a
                default value when no previous or next value exists. You can insert a constant value
                or <code>current()</code> as a default value.
              </p>
              <div>
                <p>Examples:</p>
                <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"default": "3000-01-01T00:00:00.000Z" </code></pre>
                <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"default": "current()"</code></pre>
              </div>
            </td>

          </tr>
        </tbody>
      </table>

The following table describes the attributes in the `expression` section when creating a derived field based on a SAQL expression.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:20%">
          <col style="width:20%">
          <col style="width:60%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41907e390">Parameter</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41907e393">Required?</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d41907e396">Value</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e390 ">saqlExpression</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e393 ">Yes</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e396 ">
              <p>SAQL expression used to calculate the value for the derived field. The
                expression can be based on input fields or other derived fields in the
                transformation. You can use the offset functions <code>current()</code>,<code>first()</code>,<code>next()</code>, and <code>previous()</code> in the expression.</p>
              <div>
                <p>Example to calculate the percentage
                  change from the previous amount to the current
                  amount:</p>
                <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"saqlExpression": "(current(Amount)-previous(Amount))/previous(Amount)*100"</code></pre>
              </div>
              <p>You
                can also use the SAQL case operator in the expression.</p>
              <div>
                <p>Example to output
                  <kbd>Up</kbd>, <kbd>Down</kbd>, or <kbd>No
                    Change</kbd> values based on the change from the previous amount to the
                  current
                  amount:
                </p>
                <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code> "saqlExpression": "case when current(Amount)&gt;previous(Amount) then "Up" when
      current(Amount)&lt;previous(Amount) then "Down" else "No Change" end"</code></pre>
              </div>
            </td>

          </tr>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e390 ">type</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e393 ">Yes</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e396 ">
              <p>CRM Analytics field type associated with the field. Valid types are Date,
                Numeric, and
                Text.</p>
              <div>
                <p>Example:</p>
                <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"type": "Text"</code></pre>
              </div>
            </td>

          </tr>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e390 ">scale</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e393 ">No</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e396 ">
              <p>The number of digits to the right of the decimal point in a numeric
                value.</p>
              <div>
                <p>Example:</p>
                <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"scale": 2</code></pre>
              </div>
            </td>

          </tr>
          <tr class="">
            <td data-label="Parameter" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e390 ">default</td>

            <td data-label="Required?" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e393 ">Yes (for numeric fields only)</td>

            <td data-label="Value" class="slds-cell-wrap" style="vertical-align:top;" headers="d41907e396 ">
              <p>The default value if one can’t be
                calculated.</p>
              <div>
                <p>Example:</p>
                <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>"default": "null"</code></pre>
              </div>
            </td>

          </tr>
        </tbody>
      </table>