Sort TFS Query By Itaration Start Date - tfs

I have TFS/AzureDevOps query which is sorted by Iteration Path .
I need to sort it by Iteration Start Date.
I dont see any option on the Sorting Page or in the query page to sort like this.
I tried sorting by iteration ID but the iteration were not created in order .
WIQL Code
SELECT
[System.IterationPath],
[Prod.Versions],
[System.Id],
[Prod.Territory],
[Prod.Customer],
[System.Title],
[System.AssignedTo],
[System.State]
FROM workitems
WHERE
[System.TeamProject] = #project
AND [System.WorkItemType] = 'Feature'
AND [Prod.Versions] >= '9.0'
AND [System.IterationPath] <> 'Machine'
AND [System.AreaPath] UNDER 'Machine\Development'
ORDER BY [System.IterationId],
[System.Id]
i would like it to be ordered like the following (this is from the setting page of the project in AzureDevops Server 2019 ):

We have adopted a naming convention for our iterations that uses the start date of the iteration as the name in order to achieve this.
So the iterations are named like:
2019.08.12
2019.08.26
not ideal, and I would love to see a option to include the iteration's start date a column for this very reason. Hopefully we will see a better answer soon.

Sorry, TFS work item query not support to filter Iteration using Start/End Dates.
There is a similar question here: TFS show iteration Start and End Date on PBI
Since using a name contain iteration date is not a solution for you. As another workaround, you could try get Iterations in specific Start/End dates using TFS API. Some thing maybe helpful for your reference.
Besides, in each collection database there is a table called "tbl_nodes" that holds the start-date and the end-date.
Writing a warehouse adapter that actually picks up these dates and saves them to the warehouse. Note do not write or change anything directly in database which may lose official support.
For query work item using Iteration Start/End Dates scenario, please submit it to User Voice site at: https://developercommunity.visualstudio.com/spaces/21/visual-studio-team-services.html?type=idea Microsoft engineers will evaluate any feature request seriously.

Related

How I can select workitems with specific changes in history in last some days?

I want to select only workitems which have been changed with some specific comments in last 14 days.
Something like this:
SELECT [System.Id]
FROM workitems
WHERE [System.History] CONTAINS WORDS 'Tyry-pyry'
ASOF #today - 14
Update
We do not have this kind of operate with editor date for a specific filed such as system.history.
There is no such build-in feature from a query or wiql.
You may have to first use query [System.History] CONTAINS WORDS 'Tyry-pyry' to list all work items which history contain such word.
Then use Rest API to query all above work item's detail history information. Use conditional statements or export them in excel to filter time of the comment which contain word "Tyry-pyry" added in 14 days.
You can go in queries -> new
and make a filter like this

How to query TFS for the "x" most recent iterations, for charting purposes?

I have a TFS query that pulls in data from recent sprints, in order to display a chart on our dashboard. However, as documented:
When a chart contains more than seven items within the data series, values in the eight-plus items are consolidated into a set labeled "other"
This is exactly what happens with us. The first few Iterations on the chart are static, and as every Iteration passes by, the "Other" row increases.
How can I alter my query to only pull in the last seven iterations? I can't do something like Iteration ID >= #Current Iteration - 6 because #Current Iteration is supported only for Iteration Path, not Iteration ID.
There isn't any way to achieve this through in TFS for now.
However for VSTS, it's added now.
The deployment of this feature to all VSTS accounts is now complete.
You can find full details in our Release Notes
(https://learn.microsoft.com/en-us/vsts/release-notes/2018/mar-05-vsts#query-work-across-the-iteration-schedule-with---currentiteration).
TFS customers can look forward to the feature in a future feature
update.
Source Link
Query work across the iteration schedule with +/- #CurrentIteration
The #CurrentIteration macro that helps your team track work based on your iteration schedule now supports integer offset. Easily keep tabs on the work that didn’t get closed with #CurrentIteration - 1, or look ahead at the work planned for future iterations with #CurrentIteration + 1. See the #CurrentIteration post on the Microsoft DevOps Blog for more information.
Update:
Logical expression: Work Item Type = any And State= any AND (Iteration= CurrentIteration OR Iteration= CurrentIteration-1 OR...)

How can I query customized board column change date in TFS 2017

I know you can query by state change date instead of column change date if you are using the default columns that match the state. But our TFS board columns are custom. I can see the board column changes in the work item history, so they are clearly stored somewhere. I'm happy with help on a query or if there is some way to do it through the query tool that I haven't figured out.
Thanks.
You can only list work items with Kanban query fields, but can't get column change date.
You need to use TFS api to get work items revisions, and check whether System.BoardColumn field is changed in any revision.

How to get TFS query result but for a previous date

Is it possible to execute a TFS query and get the results not for today but for a previous date?
I just want to see the results that were available in that date.
To clarify: I need to see the state of the work items on a give date to see their evolution over time.
According to your clarification, you need see the state of the work items on a give date. There is not a direct way to achieve it in Work Item Query.
You can only use Was Ever in Work Item Query to list items based on State past assignments, like:
state Was Ever Active
Or you can use State Change Date <= YYYY-MM-DD and State Change Date > YYYY-MM-DD to list all work items that changed State on YYYY-MM-DD. (Need to check whether TFS 2010 has State Change Date field)
Of course you can combine other clauses to narrow down the query.
What you want is actually the work item history. You need to get the work item history programmatically using TFS API. You can check this blog below to use the API:
http://www.codeproject.com/Articles/243653/TFS-SDK-Work-Item-History-Visualizer-using-TFS-API
I think you can create pivot table report to connect to TFS cube. For your requirement to see work items' evolution over time, you can define the pivot table as:
Check these two links for the details: https://msdn.microsoft.com/en-us/library/ms244678 and https://msdn.microsoft.com/en-us/library/ms244710.aspx

Find WorkItems that were assigned to X in the last 30 days

I'm trying to find all WorkItems that were assigned to a person X in the last 30 days.
The big problem I have is the "in the last 30 days"-part.
I thought about using the "ever" or "asof" keywords, but couldn't find a good answer yet.. something like WHERE [Assigned To] = 'X' AND (([Assigned To] != 'X') asof '<30daysago>').
But this is still not a bulletproof solution.
Any better ideas?
Thanks & kind regards
Simon
It appears that this is not possible using just WIQL, but you can get close.
The keyword #Today will give you today's date, then just subtract your range from it. The EVER keyword applied to [Status]='AssignedTo' and a comparison against a date 30 days in the past to [StateChangeDate] is what you'll need to accomplish this.
As close as you can get with WIQL and existing fields:
This says, from all revisions (status changes) return records where the user 'X' has ever been AssignedTo and the State has changed in the last 30 days. This will basically give you a slightly fuzzy picture of what your User has been working on in the last month.
WHERE [Microsoft.VSTS.Common.StateChangeDate] >= #today - 30
AND [System.AssignedTo] EVER 'Bennett Aaron'
ORDER BY [System.State]
Add the missing field:
You could add a custom field called AssignedDate that is captured during the New->AssignedTo workflow transition that you create in the Work Item Definition XML. You can accomplish this using the Team Foundation Server Power Tools extension to Visual Studio. This would give you exactly what you need as well as additional reporting options going forward.
TFS API
I cannot help you with this one, but I believe you could query using the TFS API.
A couple of quick gotchas I've experienced to save you time on ASOF and EVER:
AsOf won't help you by itself with this as it does not support a range of dates. It allows you to query as if it were another date. In other words, if you forgot to capture the results of a query yesterday, you can use an AsOf query to get the results that you would have gotten had it run yesterday. What I understand is that you want to query a basic date range.
EVER might not work as you expect against dates as I believe it uses the exact value of the field (timestamp portion of the date field would be included) it tests with. Just make sure the EVER keyword is used against the status field rather than a date.

Resources