Edit

Share via


Query by field value comparisons

Azure DevOps Services | Azure DevOps Server | Azure DevOps Server 2022 | Azure DevOps Server 2020

Use comparison field operators when you want to filter work items by comparing one field's value to another field's value. Common uses include:

  • Find work items where the creator differs from the assignee or the closer.
  • Find tasks whose Original Estimate is less than the Completed Work.
  • Find closed tasks that completed before their Target Date.

Prerequisites

Category Requirements
Access levels - To view and run shared queries: Project member.
- To add and save a shared query: At least Basic access.
Permissions Contribute permission set to Allow for the folder that you want to add a query to. By default, the Contributors group doesn't have this permission.

Note

Users with Stakeholder access for a public project have full access to query features just like users with Basic access. For more information, see Stakeholder access quick reference.

Category Requirements
Access levels - To view and run shared queries: Project member.
- To add and save a shared query: At least Basic access.
Permissions Contribute permission set to Allow for the folder that you want to add a query to. By default, the Contributors group doesn't have this permission.

Supported data types

You can use the comparison operators — =[Field], <>[Field], >[Field], <[Field], >=[Field], <=[Field] — with the following listed data types. The data type of the left-hand Field and the right-hand Field must match.

  • Boolean (supports =[Field], <>[Field])
  • Date/Time
  • Double, Integer
  • GUID
  • Identity
  • String (excluding Tags)

Note

Some data type/operator combinations are nonsensical (for example, Title >= [Field] or Assigned To <= [Field]). Validate your comparison to ensure both sides use compatible data types.

Sample filters

Use these example clauses as a starting point. Exact syntax in the Query Editor might vary slightly by client; when in doubt, build the clause in the web Query Editor and verify the saved WIQL.

  • Work items closed by someone other than the person who created the work item: [Created By] <> [Closed By] AND [State] = 'Closed'

  • Tasks whose Original Estimate is less than Completed Work: [Original Estimate] < [Completed Work]

  • Closed tasks completed before their Target Date: [Closed Date] <= [Target Date] AND [State] = 'Closed'

Fields that support field comparison

The table below lists fields that support comparison queries. Not all fields are available for every process or work item type; some require custom fields or process configuration. See the note that follows for customization links.

Note

Not all fields listed are present in every project/process. You can add custom fields and enable them for comparisons. See Add a custom field to a work item type (Inherited process) or Add or modify a field (On-premises XML process).

U–W

Note

Field-to-field comparison support differs by client. The web Query Editor supports most field comparisons; complex comparisons (for example, some uses of WAS EVER or advanced WIQL expressions) require editing WIQL directly (WIQL Editor extension). When in doubt, build the clause in the web Query Editor and inspect the saved WIQL.

REST API

To programmatically interact with queries, see one of these REST API resources:

Tip

If you need reference names for WIQL or REST (for example System.IterationId or Microsoft.VSTS.Common.Priority), see Work item fields and attributes.