Formula building in a calculated metric definition
Summarize
Summary of Formula building in a calculated metric definition
In ServiceNow's calculated metric definitions, formulas are constructed using operands (metric definitions), operators (such as +, -, , /), and functions to calculate metric data. This capability enables you to derive new metrics by combining and manipulating existing metric data according to your business requirements.
Show less
Key Features
- Operands and Operators: Formulas use metric definitions as operands and standard mathematical operators to perform calculations, such as summing employee counts from different categories.
- Default Operand Values: You can configure default values for operands that lack data in the Calculated Metric Definition Settings table. This ensures formulas complete calculations even when operand data is missing.
- Formula Versions: Every time you save changes to a formula that has been executed, a new version is created and tracked with "Applicable from" and "Applicable to" dates, allowing you to manage and update formulas over time.
- Calculation Levels: You can specify whether formulas calculate data at the metric definition level (aggregating all child metrics) or at the entity level (creating child metrics per distinct entity). Both levels support executing and aggregating formula results.
- Formula Builder Configuration: Before building formulas, you must define the formula context, tables, and identifiers. Additionally, you can import formulas directly from Microsoft Excel spreadsheets to expedite formula creation.
- Editing and Managing Formulas: Formulas can be edited anytime to update calculation logic or apply changes historically, supporting ongoing refinement of your calculated metrics.
- Exclusions: Only scheduled metric data contributes to calculated metric definitions; ad hoc child metric data is excluded from formula calculations.
Practical Implications for ServiceNow Customers
This formula building functionality allows you to customize and automate complex metric calculations across your ServiceNow environment, improving metric accuracy and relevance. By leveraging default operand values and version control, you can maintain formula integrity and adapt calculations as your data or business needs evolve. Choosing the appropriate calculation level ensures you get either aggregated results or entity-specific insights, enhancing metric analysis and decision-making. Importing formulas from Excel offers a seamless transition if you maintain formulas externally.
In a calculated metric definition, you can build formulas using operands, operators, and functions to perform calculations on metric data.
A formula consists of operands, operators, and functions. For example, to calculate the total employee count from two metric definitions (number of male employees and number of female employees), the metric definitions are the operands, and the operator is the symbol or function that performs a specific operation on the operands to produce a result. Examples of operators include addition (+), subtraction (-), multiplication (*), and division (/).
Default values for formula operands
You can set default values for operands in the Calculated Metric Definition Settings table. When a formula encounters an operand with no value, the system applies the configured default value from this table and completes the calculation. You can activate the shipped default record or create a custom entry with preferred values for specific operands.
Formula versions
Each time you save an edited formula on a calculated metric definition that has been executed, a new formula version is created. Formula versions are listed in the Versions related list on the calculated metric definition. Each version has an Applicable from date and an Applicable to date. The Applicable to date is empty for the currently active version and is set to the day before the new version's Applicable from date when a newer version is saved.
You can edit a formula at any time, including after the calculated metric definition has been executed. For more information, see Edit a calculated metric definition formula.
Formula calculation levels
- Metric definition: If you select Metric definition in the Calculation level field, 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.
- Entity: If you select Entity in the Calculation level field and specify the calculation method using the formula builder, child metrics are created for the calculated metric definition. These metrics are created for each distinct entity associated with the metric definitions used as operands in the formula. When you select Execute, the formula is applied and the metric data is generated. When you select Aggregate, the metric data is aggregated and the calculated metric data is generated.
Ad hoc metric data from child metrics is not included in CMD formula calculations at either level. Only data from scheduled child metric tasks feeds into the CMD score. For more information, see Ad hoc metric data task limitations.