Question

I would like to create a team query for our TFS users that shows all task items where the sum of the [hours remaining] and [hours completed] fields exceed the [original estimate] value.

Now Whilst I can add a clause to the WIQL that compares one field to the value of ONE other field (Which I had to ask you kind folks in stack exchange how to do in How do I write a TFS 2010 Work Item query clause whose value is a field value? which was answered by PVitt with admirable politeness - Since I had simply failed to read the "operator" drop down properly!)

I am struggling to find a way of querying the sum of two fields.

For example:

This query clause works;

And Completed Work > [Field] Remaining Work

What I really want is something along the lines of;

And Completed Work > [Field] Remaining Work+Original Estimate

The problem is either this cannot be done, or my wild guesses as to the correct syntax for summing two field values have all been wrong.

Specifying two filenames separated with a + just yields a TF51005 error TF51005 dialog

Similarly guessing at a "macro" like Sum(Remaining Work+Original Estimate) or Sum(Remaining Work,Original Estimate) results in the same.

So is this even possible? if it is how would I go about this?

Was it helpful?

Solution

What you want is not possible. Your options are to use: 1) the object model to write C# code that iterates over the work items from a query and do the math yourself 2) run the query in excel and do the calculations and filter in excel 3) use ssrs to create a report that does the math for you

If you think this is important, you can always post your suggestion on user voice: https://visualstudio.uservoice.com

OTHER TIPS

Add a new hidden field to store the sum, install TFS Aggregator and set it up to update the hidden field when the workitem is updated.

Then perform your queries off the new field.

There may be a couple of minutes delay between updating the sum having the new value.

<AggregatorItem operationType="Numeric" operation="Sum" linkType="Self" workItemType="Task">
<TargetItem name="Total Work"/>
<SourceItem name="Remaining Work"/>
<SourceItem name="Original Estimate"/>
</AggregatorItem>

If you're soley focused on the results/don't mind a (short) trip outside TFS, what I do is run the TFS query that produces the individual results I need, then just select all/copy/paste the results grid into Excel. There you'll have access to all Excel's suming and auto (col headers)/advanced filtering capabilities. You can define criteria that reference other cells using this method as well. Can also use the "If()" fcn to (in/ex)clude cell values in straight formulas. W/ some Excel fancy footwork, should even be able to preserve the summing fcns btw runs/pastes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top