Share via


Query Fields, Operators, Values, and Variables (Team Explorer Everywhere)

When you create a query to search for work items, you can define one or more clauses that identify the set of work items that you want to find. For each clause, you can specify a field, an operator, and a value or variable. For example, you can search for all work items in a particular team project by specifying the Team Project field, the equals (=) operator, and the name of the team project as the value. Instead of specifying a value, you can specify a variable such as @Project, which represents the current team project.

The following table shows a sample query clause:

And/Or

Field

Operator

Value

And

Project Name

=

@Project

For more general information about queries, see Finding Bugs, Tasks, and Other Work Items (Team Explorer Everywhere). For information about how to navigate within the query editor or query view by using keyboard shortcuts, see Keyboard Shortcuts for the Query Editor and Query Results View (TEE).

In this topic

Checklist for how to define a query clause:

  1. In the first empty row, click under the Field column heading, click the down arrow to display the list of available fields, and click an item in the list.

    For more information, see Query Fields and Values.

  2. In the same row, click under the Operator column heading, click the down arrow to display the list of available operators, and click an item in the list.

    For more information, see Query Operators.

  3. In the same row, click under the Value column heading.

  4. Type a value, or click the down arrow, and click an item in the list.

    For more information about how to use variables to specify the current team project, user, or date, see Query Variables.

  5. To add a clause, click * in the left-most column.

    Note

    You must populate the fields of the added clause before you can add a second clause.

    You can add a clause to the end of the query or between existing clauses, and you can remove, group, and ungroup clauses as needed. You can also copy and paste the contents of a clause to another location. For more information, see Specify Query Criteria.

And/Or

You can use this column to specify how clauses are tested. You specify And if you want to find work items that meet the criteria in both this clause and the previous clause. You can specify Or if you want to find work items that meet the criterion in either this clause or the previous clause.

Query Fields and Values

When you specify a value for each field, the value must conform to the data type of that field. All fields in Team Foundation have one of the data types listed in the following table:

Data type

Data stored

DateTime

A Coordinated Universal Time (UTC) moment in time. You can specify a variable, such as @Today or @Today-1, or a value, such as 1/1/2009.

Double

A real number, such as 0.2 or 3.5.

GUID

A character string that represents a unique ID.

HTML

Text strings that support formatted descriptions.

Integer

A 32-bit integer that is signed, such as 0, 1, 2, or 34.

PlainText

A text string that supports long descriptions, such as the Description or History fields. You can find work items based on a phrase or keyword that is contained within a PlainText field.

String

A text string that contains up to 255 Unicode characters.

TreePath

A branching tree structure, such as an Area Path or Iteration path. You must click an item in a list of valid values. You can find work items that equal or are under a tree structure.

Query Operators

You can use query operators in the following table to specify how each value in a clause must relate to the corresponding value in a work item.

Query operator

Returns work items if the value in the work item matches the criteria listed

Applicable field types

=

Matches the value in the clause.

Number, Text, Date, Tree

<>

Does not match the value in the clause.

Number, Text, Date, Tree

>

Is more than the value in the clause.

Number, Text, Date

<

Is less than the value in the clause

Number, Text, Date

>=

Is more than or equal to the value in the clause.

Number, Text, Date

<=

Is less than or equal to the value in the clause.

Number, Text, Date

=[Field]

Matches the value that is contained in the specified field.

Any field that is of the same data type as the specified field

<>[Field]

Does not match the value that is contained in the specified field.

Any field that is of the same data type as the specified field

>[Field]

Is more than the value that is contained in the specified field.

Any field that is of the same data type as the specified field

<[Field]

Is less than the value that is contained in the specified field.

Any field that is of the same data type as the specified field

>=[Field]

Is more than or equal to the value that is contained in the specified field.

Any field that is of the same data type as the specified field

<=[Field]

Is less than or equal to the value that is contained in the specified field.

Any field that is of the same data type as the specified field

Contains

Contains the text value in the clause.

Text

Does Not Contain

Does not contain the text value in the clause.

Text

In

Matches any value in a comma-delimited set. For example, you can find work items whose IDs are 100, 101, and 102 if you specify those values for the ID field.

Number, Text, Date, Tree

In Group

Matches a value that is a member of the group in the clause. For example, you can use this field to find all work items that are assigned to any member of a distribution list.

String or the name of a category group

NoteNote
You can use the In Group operator with only those fields that use the String data type or the Work Item Type field.

For information about category groups, see the following page: Grouping Work Item Types into Categories.

Not in Group

Does not match any values that are members of the group in the clause.

String or the name of a category group

NoteNote
You can use the Not In Group operator with only those fields that use the String data type or the Work Item Type field.

For information about category groups, see the following page: Grouping Work Item Types into Categories.

Was Ever

Matches the value in the clause at any previous point.

Text, Date

Under

Matches the value in the clause or is contained under the node in the clause.

Tree

Not Under

Does not match the value in the clause and is not contained under the node in the clause.

Tree

Query Variables

You can use the variables in the following table to find work items that relate to the current user, the current project, or the current date.

Query variable

Usage

@Me

Use this variable to automatically search for the current user's alias in a field that contains user aliases. For example, you can find work items that you opened if you set the Field column to Opened By, the Operator column to =, and the Value column to @Me.

@Project

Use this variable to search for work items in the current team project. For example, you can find all the work items in the current team project if you set the Field column to Team Project, the Operator column to =, and the Value column to @Project.

@Today

Use this variable to search for work items that relate to the current date or to an earlier date. You can also modify the @Today variable by subtracting days. For example, you can find all items that were activated in the last week if you set the Field column to Activated Date, the Operator column to >=, and the Value column to @Today - 7.

[Any]

Use this variable to search for work items that relate to any value that is defined for a particular field.

See Also

Tasks

Specify Query Criteria

Add, Remove, Reorder, and Sort Columns (Team Explorer Everywhere)

Save, Copy, Rename, and Delete Work Item Queries (Team Explorer Everywhere)

List Work Items (Default Flat List) (Team Explorer Everywhere)

Other Resources

Finding Bugs, Tasks, and Other Work Items (Team Explorer Everywhere)

Sharing Work Items and Queries with Team Members (Team Explorer Everywhere)