Comparing field values
Summarize
Summary of Comparing field values
Field comparison in ServiceNow enables users to evaluate equality or relational conditions between fields within the same table or across related tables. This functionality is often used in filters, list views, and reports to identify records based on matching or differing field values. It supports various field types including string, choice, integer, boolean, reference, and date/time fields. Date comparisons can also assess whether two dates fall within a specified range.
Show less
Key Features
- Operators for comparison:
- is same: True if two field values are identical.
- is different: True if two field values differ.
- is less than: For date fields, true if dates are within a user-defined range.
- is more than: For date fields, true if dates exceed a user-defined range.
- Choice field comparison: Compares the dictionary Value of choices, not the Label. This distinction is important for accurate filtering.
- Empty fields handling: By default, filters exclude empty fields. To include them, add an [is empty] condition on the left operand.
- Operand and operator dependencies: The left operand’s field type and chosen operator restrict available right operands to compatible fields (e.g., string fields compare with string fields).
- Date comparisons: Allow matching on specific date components (hour, day, week, etc.) and evaluating if dates fall within a specified range relative to each other, considering the user's timezone.
- Field types supported: String, choice, integer, boolean, reference, date/time fields. Not supported are journal, keyword, script, duration, list, or HTML fields.
Practical application for ServiceNow customers
Using field comparison filters, you can create precise queries such as identifying incidents where the caller is also the closer, or comparing planned versus actual dates to monitor task timelines. When working with date fields, be mindful of the user’s timezone as it influences the evaluation. For choice fields, use the dictionary values to ensure accurate comparisons. Additionally, to include records with empty values in your results, explicitly filter for emptiness.
These capabilities enhance your ability to generate accurate reports and views by leveraging relationships and temporal data, helping to improve data quality and operational insights.
Field comparison allows users to evaluate equality between fields on the same table or on related tables by using operators in the condition builder.
Also, you can compare date type fields to determine whether the values are within a certain range of each other. For example, you can compare the planned start date of a task to the actual start date. You can use field comparisons in a list view and to generate reports.
The primary function of field comparison is evaluating whether two fields on a record or related record have identical values. For example, you can create a filter to display all incidents whose Caller field references the same user record as the Closed by field.
Available operators
- [is same] if two field values are the same, evaluates to true.
- [is different] if two field values are not the same, evaluates to true.
- [is less than] if two date values are within a user-defined range of each other, evaluates to true.
- [is more than] if two date values are not within a user-defined range of each other, evaluates to true.
Comparing choice list values
Field comparison compares the dictionary Value field of a choice list, not the Label value. For example, a high priority incident has a priority value of 1, not 1 - High. To find the Value of a choice, right-click the field label and select Configure Dictionary. The Choices related list shows the Value for each choice.
Comparing empty fields
By default, most filter operations do not return empty fields in their result set. To include records with empty fields in a result set, add a filter condition for the left operand with an operator of [is empty]. For more information, see Filtering on empty fields.
Using operators and operands
When comparing fields, the two fields being compared are called the left operand and right operand. The type of field selected in the left operand, and the operator selected, determine which right operands are available. When using the [is same] or [is different] operators, the right operand choices include only fields of the same field type, such as String or Integer, as the left operand.
For example, a filter on the Task [task] table with a left operand of [Opened by] and an operator of [is same], only allows you to choose user reference fields, such as the [Closed by] field, in the right operand.
The [is more than] and [is less than] operators are only available with date type fields.
Comparable fields
- String, choice, integer, and boolean fields: Return true if both values match.
- Reference fields: Return true if both reference fields refer to the same record.
- Date and time fields: Can match date values based on hour, day, week, month, quarter, or year. Also, you can evaluate whether two dates fall within a certain range of each other.
Comparing dates
Date comparison allows you to evaluate equality between two components of the date, such as the hour of the day or the date within a month. Also, you can evaluate if two dates fall within a certain range of each other.
Date comparisons are based on the active user's time zone. For example, as a user in the PST time zone, a filter of [Created] [is same] [Day] as [Closed] evaluates true for an incident created at 6 AM PST and closed at 3:00 PM PST as both times are within the same day. However, a user in the GMT time zone would not see this same incident record in response to the example filter; in GMT those times do not fall on the same date.
You can Evaluate equality between date values and you can evaluate unequal dates within a range.
Evaluate unequal dates within a range
| Choice field | Date Comparison Choices |
|---|---|
| Operator | is more than, is less than |
| Unit of time | Hours, Days, Weeks, Months, Quarters, Years |
| Relative position of dates | before, after, before or after |