Hi There,

Thank You for visiting my blog. I have moved this blog to a new address http://dattatreysindol.com/. Please visit the blog at new address and re-point your feeds to the new address to continue to receive regular updates.
Thanks,
Dattatrey Sindol (Datta)

Datta's Ramblings on Business Intelligence 'N' Life

Applying Logical Operators in TFS Work Item Queries

» 10 Jun 2011 | | |

Last day I was querying the work items in TFS to track the status of some of the work items. Usually I used to query the work items (Bugs, Tasks etc.) which are assigned to me. However, last day I needed to query the work items which are assigned to couple of other team members as well. I was able to easily add all the clauses in the query except for the "Assigned To" where I had to do a logical OR operator. Let's take a look at what my query looked like and how I got it working :)


So, basically I wanted the following output using the above query:

"List of all the Work Items which are Assigned To either of my 2 team members (2nd & 3rd Assigned To clauses in the above screenshot), which are not in a Closed State (They can be in Active, Resolved etc. states)".

Here is a pseudo code which is equivalent of the query in the above screenshot.

SELECT [All Types of Work Items]
FROM [One or More TFS Backend Database Tables]
WHERE
[Work Item Assigned To] = "1st Team Member"
OR [Work Item Assigned To] = "2nd Team Member"
AND [Work Item State] <> "Closed"

But I wanted my query to be something like this:

SELECT [All Types of Work Items]
FROM [One or More TFS Backend Database Tables]
WHERE
(
  [Work Item Assigned To] = "1st Team Member"
  OR [Work Item Assigned To] = "2nd Team Member"
)
AND [Work Item State] <> "Closed"


Now, as we can see that the output which I wanted as stated above, can be achieved using the above query. And as we can see that, the difference between the above two queries is the presence of brackets in the 2nd query which makes it logically correct.

But I was not able to achieve the equivalent of the 2nd query in TFS. After doing some research, I figured out that there is an option to Group Clauses in Work Item queries. Select the Clauses which you want to group (Hold shift key and select multiple clauses present one after the other in a sequence), right click and select Group Clauses from the context menu as shown below:


Once the clauses are grouped, then the TFS Work Item query looks something like this.


Now, in case we need to remove those brackets (grouping) then we just need to select the same set of clauses, right click and select Ungroup Clauses from the context menu as shown below.


It's as simple as that !!!

Reference: How to: Group or Ungroup Work Item Query Clauses on MSDN

Readers Feedback:
Did you like this article?
If Yes, then please share it:
Did you like my blog?
If Yes, then please help spread the word by sharing this blog with your colleagues, friends, & anyone else in the MSBI Space: Like us on Facebook , Follow us on Twitter .

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

About the Author

Dattatrey Sindol is a BI Tech Lead & a passionate SQL Server Developer in a leading IT company.  read more »
Connect with Datta:

Thank You Visitors!

Hi There, Thanks for Visiting my Blog. Please feel free to leave your Comments/Suggestions about any of my Articles/My Blog.

Do Not Copy this Blog's Content !

Protected by Copyscape Online Copyright Checker