Learn how to add a formula to a search.

You can add a formula directly within a search. Some common reasons for using a formula in a search are to perform mathematical functions, check for and replace null values, or add conditional logic.

How to add a formula

To create a formula in a search:

  1. Start a new search, or choose an existing answer to edit.

  2. In the upper-right side of the table, click the three-dot Actions icon and select Add formula. If Answer V2 Beta is on in your environment, open the Data panel from the upper right corner if it is not open, and click the + icon next to Formulas.

    Click + to add a formula

  3. Name and enter your formula in the Formula Editor. Formula Editor V2 supports multi-line wrapping of long formulas. To continue the formula on a new line, press Enter or return on your keyboard.

    Use the Formula Editor

  4. You can see a list of formula operators with examples by clicking Formula Assistant. If Answer V2 Beta is on in your environment, select the help icon ? in the upper right corner. Expand a category, such as Comparison, and click on an operator for a definition and example.

    Formula Editor help

  5. To change what your formula returns, use the Advanced Settings. If Answer V2 Beta is on in your environment, select the settings icon in the upper right corner. Depending on your formula, you may be able to change the following aspects:

    • Data type: Determines the type of data that the formula generates. For example, use date for an add_days formula.
    • Measure or attribute: Determines if the output of the formula is a measure or an attribute. For example, choose attribute for a formula that generates age groups, and choose measure for a formula that generates profit.
    • Aggregation: Determines the default aggregation of the formula output. For example, choose min to see minimum profit.

    Advanced settings in the Formula Builder

  6. Click Save.

Formula function reference