---
schema_version: "1"
id: b9a1b51367271acb9198824fbee92513be445b74b92ee31d2aee2a589e35242a
title: "Examples: Evaluate Each Record in Reports with Row-Level Formulas"
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/analytics/264-0-0/reports_formulas_row_level_examples.md
canonical_url: https://help.salesforce.com/s/articleView?id=analytics.reports_formulas_row_level_examples.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 4571e9b87bda485cc687f709940b5117d030becbfbb5b0d324ad5b14667847f4
description: "\"How many days did it take each opportunity to close? Which case subjects mention the word widget?\" Here's how to write row-level formulas that answer these business questions, and others."
products:
  - Cross Cloud
release: "264"
---
# Examples: Evaluate Each Record in Reports with Row-Level Formulas

"How many days did it take each opportunity to close? Which case subjects mention the word widget?" Here's how to write row-level formulas that answer these business questions, and others.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Essentials</strong>, <strong>Group</strong>, <strong>Professional</strong>, <strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Enhanced Folder Sharing</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
      <colgroup>
        <col style="width:50%">
        <col style="width:50%">
      </colgroup>
      <thead class="slds-text-title_caps ">
        <tr class="">
          <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="vertical-align:top;" id="d75856e89">User Permissions Needed</th>
        </tr>
      </thead>
      <tbody>
        <tr class="">
          <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d75856e89 ">To create, edit, and delete formulas in private reports:</td>

          <td class="slds-cell-wrap" style="vertical-align:top;" headers="d75856e89 ">
            <dl>

              <dt style="font-weight:bold;padding-top:.25rem;">Enhanced Folder Sharing</dt>

              <dd style="padding-left:1.5rem;padding-bottom:.5rem;">Create and Customize Reports </dd>

            </dl>
          </td>

        </tr>
        <tr class="">
          <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d75856e89 ">To create, edit, and delete formulas in public and private reports:</td>

          <td class="slds-cell-wrap" style="vertical-align:top;" headers="d75856e89 ">
            <dl>

              <dt style="font-weight:bold;padding-top:.25rem;">Enhanced Folder Sharing</dt>

              <dd style="padding-left:1.5rem;padding-bottom:.5rem;">
                <p style="margin-bottom:0;">Report Builder OR Report Builder (Lightning Experience)</p>
              </dd>

            </dl>
          </td>

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

To answer common questions like these, assess each record in a report:

- How many days did it take each opportunity to close?
- Which case subjects mention the word "widget"?

The answer to these questions, and many more, are a row-level formula away. Here's how.

## Example: How many days did it take each opportunity to close?

To answer this question, create an opportunity report and write a row-level formula that subtracts the Created Date from the Closed Date.

1. Create or edit an opportunities report.
2. From the Columns section of the Outline pane, click **![the more actions icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-analytics-264-0-0-production-enus/295fead5-b71d-4e1c-9886-4af4d53400b6/analytics/images/rd/report_builder_group_menu_arrow.png)** | **Add Row-Level Formula**.
    
    ![Adding a row-level formula](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-analytics-264-0-0-production-enus/295fead5-b71d-4e1c-9886-4af4d53400b6/analytics/images/rd/rd_formulas_row_level_1.png)
3. From the Edit Summary-Level Formula Column window, write the formula.
    
    1. In **Column Name**, enter Time to Close.
    2. In **Description**, enter Time to Close in Days.
    3. From **Formula Output Type**, select **Number**.
        
        Even though this formula works with date values, number is the output type needed because the formula performs subtraction and returns a number.
    4. From **Decimal Points** to **0**.
    5. In **Formula**, write:
        
        ```
        CLOSE_DATE - DATEVALUE(CREATED_DATE)
        ```
        
        ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-analytics-264-0-0-production-enus/295fead5-b71d-4e1c-9886-4af4d53400b6/images/icon_note.png)
        
        Note
        
        - `CLOSE_DATE` and `CREATED_DATE` are the API names of the Close Date and Created Date fields. Formulas work with the API names of fields, not the display names. The easiest way to enter the API name of a field is to search for it from the FIELDS menu, select it, and click **Insert >**.
        - Because `CLOSE_DATE`'s data type is `date` and `CREATED_DATE`'s data type is `datetime`, we convert the value of `CREATED_DATE` to the `date` data type with the `DATEVALUE()` function. The two values must have a matching data type so that we can subtract one from the other. (`Datetime` and `date` are different data types because `datetime` includes information about units of time smaller than a day - hours, minutes, seconds, and so on - and `DATE` does not.)
    6. To make sure that the formula is error-free, click **Validate**. If necessary, resolve errors.
    7. Click **Apply** (5).
    
    ![Writing a row-level formula](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-analytics-264-0-0-production-enus/295fead5-b71d-4e1c-9886-4af4d53400b6/analytics/images/rd/rd_formulas_row_level_2.png)
4. To save the report, click **Save**.

The row-level formula appears as a report column named Time to Close (6). The Time to Close column calculates how many days each opportunity was open by subtracting Created Date from Closed Date.

![A row-level formula in a report](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-analytics-264-0-0-production-enus/295fead5-b71d-4e1c-9886-4af4d53400b6/analytics/images/rd/rd_formulas_row_level_3.png)

## Example: Which case subjects mention the word "widget"?

To answer this question, create a cases report and write a row-level formula that evaluates each case subject to see whether it includes the term "widget".

1. From the Columns section of the OUTLINE pane, click **![the more actions icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-analytics-264-0-0-production-enus/295fead5-b71d-4e1c-9886-4af4d53400b6/analytics/images/rd/report_builder_group_menu_arrow.png)** | **Add Row-Level Formula**.
2. From the Edit Summary-Level Formula Column window, write the formula.
    1. In **Column Name**, enter Mentions Widgets?.
    2. In **Description**, enter Determines whether or a case subject includes the term "widget".
    3. From **Formula Output Type**, select **Text**.
    4. In **Formula**, write:
        
        ```
        IF(CONTAINS(SUBJECT, "widget"), "Yes", "No")
        ```
        
        ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-analytics-analytics-264-0-0-production-enus/295fead5-b71d-4e1c-9886-4af4d53400b6/images/icon_note.png)
        
        Note
        
        - `SUBJECT` is the API name of the Subject field. Formulas work with the API names of fields, not the display names. The easiest way to enter the API name of a field is to search for it from the FIELDS menu, select it, and click **Insert >**.
    5. To make sure that the formula is error-free, click **Validate**. If necessary, resolve errors.
3. Click **Apply**.
4. Click **Save**.

The row-level formula appears as a report column named Mentions Widgets?. The Mentions Widgets? column evaluates each case's subject field to determine whether it includes the text widget. If it does, the row-level formula returns Yes. If it doesn't, the row-level formula returns No.