You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/includes/ai-assistance-mcp-server-tip.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,9 @@ ms.topic: include
10
10
ms.custom: copilot-scenario-highlight
11
11
-->
12
12
13
+
<!-- Anchor satisfies build validation; the real target is in the consuming article -->
14
+
<aname="use-ai-assistance"></a>
15
+
13
16
> [!TIP]
14
17
> You can [use AI to help with this task](#use-ai-assistance) later in this article, or see [Enable AI assistance with Azure DevOps MCP Server](/azure/devops/mcp-server/mcp-server-overview) to get started.
description: Learn how to query Analytics trend data and consume it in a client tool when working from Azure DevOps.
2
+
title: Query Trend Data With OData Aggregation in Azure DevOps
3
+
titleSuffix: Azure DevOps
4
+
description: Learn how to query trend data in Azure DevOps using OData aggregation. Filter, group, and analyze snapshot entity sets for actionable insights.
Examining trends in data and making period-over-period comparisons are important aspects of reporting and data analysis. Analytics supports these capabilities.
20
+
Analytics stores daily snapshots of every work item in two entity sets: `WorkItemSnapshot` (tracks field values like state and effort) and `WorkItemBoardSnapshot` (tracks board column positions). Because each entity contains one row per work item per day, these tables grow quickly. Use [OData aggregation extensions](aggregated-data-analytics.md) to filter by date and group results before returning data to a client tool.
Trend data is exposed in the WorkItemSnapshot and WorkItemBoardSnapshot entity sets. They're constructed so every work item, from the day it was created until today, exists for each day. For an organization with only one work item that was created a year ago, there are 365 rows in this entity. For large projects, these entities would be impractical to use with client tools.
23
-
24
-
What is the solution? Use the [Aggregation extensions](aggregated-data-analytics.md).
22
+
This article shows how to build trend queries by date range and by iteration, using `$apply` with `filter`, `groupby`, and `aggregate`.
25
23
26
-
Using the OData Aggregation Extensions, you can return aggregated data from Azure DevOps that is conducive to reporting. For example, you could show bug trend for the month of March. Bug trends are a common and critical part of managing any project so you can put it to good use immediately.
This query produces at most `31 * (number of bug states)`. The default bug has three states:
87
-
- Active
88
-
- Resolved
89
-
- Closed
90
-
91
-
At most, this query returns 93 rows no matter how many thousands of records actually exist. It provides a much more compact form of returning data.
76
+
This query returns at most 31 days multiplied by the number of bug states (Active, Resolved, Closed) - 93 rows maximum, regardless of how many work items exist.
92
77
93
-
Let's look at a variation on this example. You want to see the bug trend for an iteration or a release that starts with one iteration and ends with another.
78
+
## Query trend data by iteration
94
79
95
-
To construct that query, do the following example:
80
+
Instead of hard-coding dates, filter by iteration and reference its start and end dates so the date range adjusts automatically. The `Iteration/EndDate eq null` check handles iterations that don't have an end date yet.
In this query, there are two key differences. We added a filter clause to filter the data to a specific iteration and the dates are now being compared to the iteration start and end dates versus a hard-coded date.
132
-
133
105
> [!NOTE]
134
-
> If your query on snapshot tables doesn't use aggregation, the response displays the warning: "The specified query doesn't include a `$select` or `$apply` clause which is recommended for all queries."
106
+
> If your query on snapshot tables doesn't include `$apply` or `$select`, the response returns a warning. Always use aggregation with snapshot entity sets.
107
+
108
+
::: moniker range="azure-devops"
109
+
110
+
## Use AI to build trend queries
111
+
112
+
If you configure the [Azure DevOps MCP Server](/azure/devops/mcp-server/mcp-server-overview), you can use AI assistants to help construct and troubleshoot trend queries against snapshot entity sets.
113
+
114
+
### Example prompts
115
+
116
+
| Task | Example prompt |
117
+
|------|----------------|
118
+
| Bug trend query | `Write an OData trend query that shows the daily bug count by state over the last 30 days in <Contoso> project` |
119
+
| Sprint snapshot | `Create an OData query against WorkItemSnapshot that shows work item counts grouped by date for the current sprint in <Contoso> project` |
120
+
| Filter by iteration | `Generate an OData trend query that uses iteration start and end dates to show story point burndown in <Contoso> project` |
121
+
| Board snapshot | `Write an OData query against WorkItemBoardSnapshot to track items by board column over the past two weeks in <Contoso> project` |
122
+
| Optimize performance | `My WorkItemSnapshot trend query is timing out — help me add proper date filters and aggregation to improve performance in <Contoso> project` |
123
+
| Period comparison | `Create an OData trend query that compares bug counts between the current sprint and the previous sprint in <Contoso> project` |
124
+
| Remaining work trend | `Write an OData trend query that shows the daily sum of remaining work by area path for the current iteration in <Contoso> project` |
125
+
| Detect state changes | `Create an OData snapshot query that tracks how many work items moved from Active to Resolved each day over the past 60 days in <Contoso> project` |
126
+
| Scope change analysis | `Generate an OData trend query that shows the daily count of user stories added or removed from a sprint by comparing snapshot data in <Contoso> project` |
- [OData Extension for Data Aggregation Version 4.0](https://docs.oasis-open.org/odata/odata-data-aggregation-ext/v4.0/cs01/odata-data-aggregation-ext-v4.0-cs01.html)
0 commit comments