Example queries

Last Update: 3/7/2017

Team Services | TFS 2017 | TFS 2015 | Previous versions

A query lists a filtered set of work items. You can initiate a query using the work item search box or through the query editor.

With queries, you can perform these functions:

  • List items to perform bulk updates, assign or reassign
  • Review work that's in progress or recently closed
  • Triage work (set priority, review, update)
  • Create a chart and add it to a dashboard
  • Create a chart to get a count of items or sum a field
  • Create a chart that shows a burndown or burnup over time
  • View a tree of parent-child related work items

For the mechanics of constructing and saving queries, see Using queries. For specific examples, click one of the following links.

You can list work items based on the following criteria...

Example search box queries


If your admin has installed the Work item search extension, the search box will perform an adhoc query using the extension. You'll no longer be able to initiate a managed search. Instead, you'll need to open the Work>Queries page and construct a query. To learn more, see Adhoc vs managed work item queries.

You can initiate your query from the work item search box. You can find items using shortcut filters or by specifying keywords or phrases, specific fields/field values, assignment or date modifications, or using Equals, Contains, and Not operators.

Search box queries automatically scope to the items defined to the team project you're currently connected to. To search across team projects, use the query editor. Also, searching is not case-sensitive.

Use shortcut filters

Open the Context Menu Icon context menu and select an option.

Context menu for search box (web portal)

Search box shortcut menu (web portal)

Context menu for search box (Team Explorer)

Search box menu (Team Explorer)

You can enter or select one or more of the following shortcut identifiers:

  • A =for Assigned To, (for example, A:Annie or A=@me).

  • C for = Created By, (for example, C:Peter or C=@me).

  • S for = State, (for example, S=New).

  • T for = Work Item Type, (for example, T=Task).

Use the @Me and @Today macros to specify your user name or today's date.

Use the =, :, and operators to specify the operations Equals, Contains, and Not, respectively.

Finding work items using the search box (Team Explorer)

Find a work item using the search text box

You can combine shortcuts and use search operators within the search box.

In Team Explorer, use the Search box clear icon (Team Explorer) Clear button to remove content from the search box. To switch your context to the search box from within Visual Studio, enter Ctrl+'.

Find items based on keywords or phrases

Keywords or phrases that you type into the search box return a list of work items that contain those keywords or phrases in the Description, Repro Steps, or Title fields. You must enclose each phrase in quotation marks.

In the Search work items box, type a keyword or phrase that appears in the Title, Description, or Repro Steps fields for the work items of interest.

Enclose multiple words in quotation marks.

For example, to find work items with the specified keywords in the Title or Description fields:

  • For the keyword "duplication" enter duplication.
  • For the phrase "Getting Started" enter "Getting Started".
  • For the phrase "Getting Started" or the keyword "feature" enter feature "Getting Started".
Filter for items that contain these keywords or phrases: Type the following string:
duplication duplication
Getting Started "Getting Started"
feature and Getting Started feature "Getting Started"

You can perform partial or exact match queries on a keyword or a phrase contained within any text field. Or, you can perform a full-text search query by filtering on keywords and phrases contained within the full-text search index. Team Foundation automatically indexes all long-text fields with a data type of PlainText and HTML and the Title field for full-text search.

Find items based on specific fields and field values

To find work items based on a keyword or phrase contained within other text string fields, specify either the friendly name or the reference name of the field. Enclose each phrase in quotation marks. You can determine the friendly name of a field by hovering over the field within a work item form. To determine the reference name of commonly used fields or to find a field that is not listed on the form, see Work item field index.

Filter for items that meet this criteria: Type the following string:
Contains one attached file. System.AttachedFileCount=1
Cut user stories. T:Story Reason=Cut
T="User Story" System.Reason=Cut
Resolved by Peter. "Resolved By":Peter
Modified today. "Changed Date"=@Today
Created yesterday as a test activity. "Created Date"=@Today-1 Activity=Test

Some fields, such as History and Description, do not support partial word text searches. For example, if the History field contains the phrase reproducible behavior and you search for History:repro the work item will not be found. However, if you search for the complete string History:reproducible the work item will be found.

Use @Me or @Today macros

The @Me macro expands to the full name of the current user in any work item search. The @Me macro is especially useful for creating a search that you can share with other users, and it can simplify your work by reducing the number of characters you must type to specify your own user name.

Filter for Type the following string
Currently assigned to you A=@Me
Created by you C=@Me
Resolved yesterday "Resolved Date"=@Today-1
Modified 7 days ago System.ChangedDate=@Today-7
Created yesterday under the Phone Saver team            Created Date _ = _ @Today-1
And _ Area Path _ = _ FabrikamFiber\Phone Saver

Use Equals, Contains, and Not operators

Use these search operators to specify search criteria:

   = (EQUALS) to search for exact matches of text.
   : (CONTAINS) to search for partial matches of text.
    (NOT) to exclude work items that contain certain text. The NOT operator can only be used with field names.

The following examples show how to use operators when you create a search string.

Filter for items that meet this criteria: Type the following string:
Assigned to Peter and not Active. A:Peter -S=Active
In which the Activity field was not Development. - Activity=Development
Resolved by Peter. "Resolved By":Peter
Contain the keyword triage in the title or description, are not assigned to you, and are not closed. triage -A=@me -S=Closed
Active bugs that are assigned to you that do not contain the keyword bugbash in the title. S=Active T=bug A=@Me -Title:bugbash

Query across team projects

By default, shared queries and new queries are scoped to the current team project. However, you can create queries to find work items defined within the team project collection. You save cross-project queries under a specific team project.


Feature availability: The Query across projects feature is supported from Team Services and the web portal for TFS 2015.1 or later version.

Team Services and TFS 2015.1

To list work items defined in two or more team projects, checkmark Query across projects. For example, the following query finds all features created in all team projects within the last 30 days.

Check Query across team projects

With the Query across projects checked, you can add the Team Project field to filter to a select number of team projects.

Query across select team projects using the In operator


Separate multiple project names with the list separator that corresponds to the regional settings defined for your client computer, for example, a comma (,).

The Team Project field becomes available only after you check Query across projects. Moreover, when Query across projects is unchecked, only those fields from those WITs defined in the current team project appear in the Field drop-down menu. When Query across projects is checked, all fields from all WITs defined in all team projects in the collection appear in the Field drop-down menu.

TFS 2015

To find all features created in all team projects within the last 30 days, remove the Team Project=@Project clause from the query.

Query across select team projects using the In operator

All fields from all WITs defined in all team projects in the collection always appear in the Field drop-down menu.

Use Team Project=@Project to scope the query to find only those work items defined for the current team project.

For more information on using work items and queries, see:

You can view related work items and object within a work item form by installing the Work item visualization extension available from the Visual Studio Marketplace.

Does the search box support less than/greater than operators?

No. The search box doesn't recognize comparison operators such as greater than (>) or less than (<). It translates queries with these operators into a search phrase.