Write a WIQL query to get number of days a bug is open - tfs

I am trying to create a query using WIQL which later I am opening in TFS.
I want a field in my bug report that shows for how many days a bug is open. Below is the query:
<?xml version="1.0" encoding="utf-8"?>
<WorkItemQuery Version="1"><Wiql>
SELECT [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State],#today-[System.CreatedDate] as 'Days' FROM WorkItems
WHERE [System.TeamProject] = #project AND [System.WorkItemType] = 'Bug'
</Wiql>
</WorkItemQuery>
When I am opening this .txt file in Visual studio as a query it is showing me an error saying 'The query statement is missing a FROM clause'.
Am I writing the correct query?
Or is there anything I should update so that the query works fine and it gives me number of days a bug is open as a field in my Bug summary.
Thanks in advance.

Azure DevOps Server (TFS) does not support calculated fields or calculated query columns. You can try to use:
Excel with formulas: Add or modify Azure Boards work items in bulk with Microsoft Excel
Powers BI reports: Calculate time-in-state for an existing Analytics view

Related

How to search for TFS items that are in still in Refinement?

I am trying to create a search query to search for TFS items that are in Refinement from a TFS board and am stuck with that.
Basically I want to be able to add a badge of amount of work items that are currently being displayed in the Refinement column in our dashboard:
When I open the relevant TFS item from the Board I can see that there is a column with value as Refinement but am not able to create a search query for that column or value:
Please help me with search query column that I can use or help write a WIQL query to lookup "in refinement" items from a TFS board.
Use "Board Column" in the search:
In WIQL you can search for the same thing like this:
[Source].[System.BoardColumn] = 'Refinement'

TFS Query to get blank (or) no entries in Acceptance Criteria field of Feature or User Story

I want to write a TFS Query to get blank (or) no entries in Acceptance Criteria field/box for Features or User Story's in project.
How can I write Query as I can't see any = or <> operators against 'Acceptance Criteria'. Only I can see 'Contains Words' & 'Does Not Contains Words', from these how can we get blank entries?
Starting with Azure DevOps 2019 Server (TFS 2019) there is a new operator for HTML fields "IsEmpty" that does what you want to do. Prior to that version you cannot do this in a query.
See: https://learn.microsoft.com/en-us/azure/devops/boards/queries/query-operators-variables?view=azure-devops#query-operators
There is no way to do this search.
you can make a full search then export the results to excel then filter there :(

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

Sort TFS Query By Itaration Start Date

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.

Azure Application insights for web, display unique users in power BI

We set up web analytics using Application Insights -> Stream Analytics -> Power BI path.
We would like to see the chart of daily unique visitors in Power BI dashboard.
Users are considered unique if [context].[user].anonId are different. Time is placed in [context].[data].eventTime in insights json.
The export query should look something like that (we know how to address missing unique keyword, so I'll use it for simplicity):
SELECT
count(unique A.[context].[user].anonId)
SYSTEM.TIMESTAMP
FROM
[export-input] A
TIMESTAMP BY A.[context].[data].eventTime
GROUP BY
TumblingWindow(day, 1)
The problem is TIMESTAMP BY does not support qualified fields. Without that, we're actually timestamping users not by actual page visit time, but by the time this data entered stream analytics. This means, we might loose a bunch of unique uesrs, or count some of them twice.
Is there a workaround for that?
TIMESTAMP BY now supports qualified fields, so it should not be a problem anymore. However, please note that Stream Analytics does not have Unique/Distinct keyword. You will need to rewrite your query like this to compute unique count:
WITH step1 AS
(
SELECT
COUNT(*) countPerAnonId
FROM
[export-input] A
TIMESTAMP BY A.[context].[data].eventTime
GROUP BY
A.[context].[user].anonId,
TumblingWindow(day, 1)
)
SELECT COUNT(*)
FROM step1
GROUP BY System.Timestamp
Could you, on the ASA side, just submit the 'view time' as a property of your event (from the client) and then select across that in ASA. I'm not that familiar with ASA's limits, but I can find someone to help if the above doesn't work. In Power BI you can make Q&A queries like "show distinct anonID in the last 24 hours" or "... in the last day". Which if there's a date field, should match your expected behavior.

Resources