Formula building in a calculated metric definition

  • Release version: Xanadu
  • Updated July 31, 2025
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Formula building in a calculated metric definition

    Calculated metric definitions in ServiceNow allow you to create formulas that perform calculations using operands, operators, and functions. These formulas enable you to derive metrics such as total employee count by combining data from multiple metric definitions. You can build formulas at either the metric definition or the entity level, depending on the desired scope of calculation.

    Show full answer Show less

    Formula Construction and Calculation Levels

    A formula combines operands (metric definitions or entities) with operators like addition (+), subtraction (-), multiplication (), and division (/). You must specify the calculation level before saving a calculated metric definition:

    • Metric definition level: Aggregates data across all child metrics or metric definitions to produce a combined result.
    • Entity level: Creates child metrics for each distinct entity associated with the operands, allowing calculations and aggregations per entity.

    Executing or aggregating the metric definition applies the formula and generates the calculated metric data accordingly.

    Key Features

    • Default operand values: You can configure default values for operands in the Calculated Metric Definition Settings table. This ensures formulas continue calculating smoothly even if some operand data is missing or undefined.
    • Formula context configuration: Define the formula context, relevant tables, and identifiers before building formulas to ensure accuracy and proper data mapping.
    • Import formulas: You can import formulas directly from Microsoft Excel spreadsheets, accelerating the formula creation process within calculated metric definitions.
    • Custom formula creation: Build formulas tailored to your needs using entities or metric definitions as operands.

    Practical Benefits

    • Improves calculation reliability by automatically handling missing data through default values.
    • Offers flexible calculation scopes (metric definition vs. entity) for detailed or aggregated insights.
    • Streamlines formula development with import capabilities and a guided formula builder setup.
    • Supports consistent metric calculations across varying data scenarios, reducing manual intervention and ensuring dependable results.

    In a calculated metric definition, you can create formulas to perform calculations for any data that you may require.

    A formula consists of operands, operators, and functions. For example, if you want to calculate the total employee count from two metric definitions namely number of male employees and number of female employees, then the selected metric definitions are the operands and the operator is the symbol or function that performs a specific operation on the operands to obtain a result. Examples of operators include addition (+), subtraction (-), multiplication (*), and division (/).

    You can set default values for operands in the Calculated Metric Definition Settings table to ensure metric calculations continue smoothly even when data is missing or undefined. When a formula encounters an empty operand, the system automatically applies the configured default value from this table, allowing the calculation to proceed without interruption. Users can activate the shipped default record or create custom entries with preferred values for specific operands. This setup enhances the reliability and flexibility of metric logic, reduces manual intervention, and supports consistent results across varying data conditions.

    When you build a formula in a calculated metric definition, you can choose to build it at either the metric definition level or at the entity level. Before you save the calculated metric definition form and build the formula for metric definition score calculation, you must specify the calculation level in the calculated metric definition form. The two levels are as follows:
    • Metric definition: If you select Metric definition in the Calculation level field, then the data across all child metric definitions or child metrics is used for calculation. When you select Execute, the formula is applied and the calculated metric definition data is generated. For more information, see Configure the formula builder. The following image shows how calculation occurs at the metric definition level: Calculation at the metric definition level.
    • Entity: If you select Entity in the Calculation level field and specify the calculation method using the formula builder, then the child metrics are created for the calculated metric definition. These metrics are created for each distinct entity that is associated with the metric definitions that have been used as operands in the formula. When you Execute the metric definition, the formula is applied and the metric data is generated. When you Aggregate the metric definition, the metric data is aggregated and the calculated metric data is generated. The following image shows how calculation occurs at the entity level:Calculation at the entity level.