Work items with direct links sample reports
Azure DevOps Services | Azure DevOps Server 2020 | Azure DevOps Server 2019
This article shows you how to list a given set of User Stories and their linked User Stories. An example is shown in the following image.

Other sample queries include listing bugs with a Duplicate link to another bug, and listing bugs that don't contain a Duplicate link to another bug.
Note
This article assumes you've read Overview of Sample Reports using OData Queries and have a basic understanding of Power BI.
Prerequisites
- You must be a member of a project with Basic access or higher. If you haven't been added as a project member, get added now. Anyone with access to the project, except stakeholders, can view Analytics views.
- For Analytics data to be available, the corresponding service must be enabled. For example, to query work tracking data, Boards must be enabled. If it is disabled, Analytics views won't be displayed. To re-enable a service, see Turn an Azure DevOps service on or off
- To use Analytics views, enable the Analytics Views preview feature either for individual users or for the organization.
- Also, you must have your *View Analytics permission set to Allow. For more information, see Grant permissions to access the Analytics service.
- To use Power BI for Azure DevOps or to exercise an OData query for Analytics, you must must have your View Analytics permission set to Allow. By default, all Contributors with Basic access are granted access. To edit shared Analytics views, you must have your *Edit shared Analytics views permission set to Allow. For more information, see Grant permissions to access the Analytics service.
- You must be a member of a project with Basic access or higher. If you haven't been added as a project member, get added now. Anyone with access to the project, except stakeholders, can view Analytics views.
- Verify that Analytics is installed, and if not, then enable it. You must be an account owner or a member of the Project Collection Administrators group to add extensions or enable the service.
- For Analytics data to be available, the corresponding service must be enabled. For example, to query work tracking data, Boards must be enabled. If it is disabled, Analytics views won't be displayed. To re-enable a service, see Turn an Azure DevOps service on or off
- To use Analytics views, enable the Analytics Views preview feature either for individual users or for the organization.
- Also, you must have your *View Analytics permission set to Allow. For more information, see Grant permissions to access the Analytics service.
- To use Power BI for Azure DevOps or to exercise an OData query for Analytics, you must must have your View Analytics permission set to Allow. By default, all Contributors with Basic access are granted access. To edit shared Analytics views, you must have your Edit shared Analytics views permission set to Allow. For more information, see Grant permissions to access the Analytics service.
Sample queries
You can paste the Power BI query listed below directly into the Get Data->Blank Query window. For more information, review Overview of sample reports using OData queries.
let
Source = OData.Feed ("https://analytics.dev.azure.com/{organization}/{project}/_odata/v3.0-preview/WorkItems?"
&"$filter=WorkItemType eq 'User Story' "
&"and State ne 'Closed' "
&"and startswith(Area/AreaPath,'{areapath}') "
&"&$select=WorkItemId,Title,WorkItemType,State,Priority,Severity,TagNames,AreaSK "
&"&$expand=AssignedTo($select=UserName),Iteration($select=IterationPath),Area($select=AreaPath), "
&"Links( "
&"$filter=LinkTypeName eq 'Related' "
&"and TargetWorkItem/WorkItemType eq 'User Story'; "
&"$select=LinkTypeName; "
&"$expand=TargetWorkItem($select=WorkItemType,WorkItemId,Title,State) "
&") "
,null, [Implementation="2.0",OmitValues = ODataOmitValues.Nulls,ODataVersion = 4])
in
Source
Substitution strings
Each query contains the following strings that you must substitute with your values. Don't include brackets {} with your substitution. For example if your organization name is "Fabrikam", replace {organization} with Fabrikam, not {Fabrikam}.
{organization}- Your organization name{project}- Your team project name, or omit "/{project}" entirely, for a cross-project query
{areapath}- Your Area Path. Example format:Project\Level1\Level2
Query breakdown
The following table describes each part of the query.
Query part
Description
$filter=WorkItemType eq 'User Story'
Return User Stories.
and State ne 'Closed'
Omit Closed items.
and startswith(Area/AreaPath,'{areapath}')
Work items under a specific Area Path. Replacing with Area/AreaPath eq '{areapath}' returns items at a specific Area Path.
To filter by Team Name, use the filter statement Teams/any(x:x/TeamName eq '{teamname})'.
&$select=WorkItemId, Title, WorkItemType, State, Priority, Severity, TagNames
Select fields to return.
&$expand=AssignedTo($select=UserName), Iteration($select=IterationPath), Area($select=AreaPath),
Expand Assigned To, Iteration, Area entities and select entity fields.
Links(
Expand the Links entity
$filter=LinkTypeName eq 'Related'
Filter to only links of type 'Related'.
Other examples are Parent, Child, Duplicate, Duplicate Of, Affects, Affected By.
and TargetWorkItem/WorkItemType eq 'User Story';
Only include links to User Stories.
$select=LinkTypeName;
Select the LinkTypeName field to return.
$expand=TargetWorkItem($select=WorkItemType, WorkItemId, Title, State)
Select the fields of the linked work item to return.
)
Close Links().
Query filters
To determine available query filters, query the metadata as described in Explore the Analytics OData metadata. You can filter your queries using any of the NavigationPropertyBinding Path values listed under an EntitySet. To learn more about the data type of each value, review the metadata provided for the corresponding EntityType. Each EntitySet corresponds to an EntityType.
For example, the EntitySet Name="WorkItemSnapshot" corresponds to the EntityType Name="WorkItemSnapshot". The OData metadata for EntitySet Name="WorkItemSnapshot" is as shown below for v4.0-preview. You can add filters based on any of the listed NavigationPropertyBinding Path values.
<EntitySet Name="WorkItemSnapshot" EntityType="Microsoft.VisualStudio.Services.Analytics.Model.WorkItemSnapshot">
<NavigationPropertyBinding Path="Date" Target="Dates"/>
<NavigationPropertyBinding Path="RevisedOn" Target="Dates"/>
<NavigationPropertyBinding Path="Teams" Target="Teams"/>
<NavigationPropertyBinding Path="Processes" Target="Processes"/>
<NavigationPropertyBinding Path="Project" Target="Projects"/>
<NavigationPropertyBinding Path="Area" Target="Areas"/>
<NavigationPropertyBinding Path="Iteration" Target="Iterations"/>
<NavigationPropertyBinding Path="AssignedTo" Target="Users"/>
<NavigationPropertyBinding Path="ChangedBy" Target="Users"/>
<NavigationPropertyBinding Path="CreatedBy" Target="Users"/>
<NavigationPropertyBinding Path="ActivatedBy" Target="Users"/>
<NavigationPropertyBinding Path="ClosedBy" Target="Users"/>
<NavigationPropertyBinding Path="ResolvedBy" Target="Users"/>
<NavigationPropertyBinding Path="Tags" Target="Tags"/>
<NavigationPropertyBinding Path="ChangedOn" Target="Dates"/>
<NavigationPropertyBinding Path="ClosedOn" Target="Dates"/>
<NavigationPropertyBinding Path="CreatedOn" Target="Dates"/>
<NavigationPropertyBinding Path="ResolvedOn" Target="Dates"/>
<NavigationPropertyBinding Path="StateChangeOn" Target="Dates"/>
<NavigationPropertyBinding Path="InProgressOn" Target="Dates"/>
<NavigationPropertyBinding Path="CompletedOn" Target="Dates"/>
</EntitySet>
Power BI transforms
Expand Area, Iteration, AssignedTo columns
The query returns several columns that you need to expand before you can use them in Power BI. Any entity pulled in using an OData $expand statement returns a record with potentially several fields. You need to expand the record to flatten the entity into its fields. Examples of such entities are: AssignedTo, Iteration, and Area.
After closing the Advanced Editor and while remaining in the Power Query Editor, select the expand button on the entities you need to flatten.
Choose the expand button.

Select the fields to flatten.

The table now contains entity field(s).

Repeat steps 1 through 3 for all fields representing entities: Area, Iteration, AssignedTo.
Expand the Links column
Select the expand button on the Links column.

Select all the fields to flatten.

Select the expand button on the Links.TargetWorkItem column.

Select the fields of the Target Work Item to flatten.

The Table now contains flattened Link and Target Work Item field(s).

Note
If the link represents a one-to-many or many-to-many relationship, then multiple links will expand to multiple rows, one for each link.
For example, if Work Item #1 is linked to Work Item's #2 and #3, then when you expand the Links record, you will have 2 rows for Work Item #1. One that represents its link to Work Item #2, and another that represents its link to Work Item #3.
Rename fields and query, then Close & Apply
When finished, you may choose to rename columns.
Right-click a column header and select Rename...

You also may want to rename the query from the default Query1, to something more meaningful.

Once done, choose Close & Apply to save the query and return to Power BI.

Create the report
Power BI shows you the fields you can report on.
Note
The example below assumes that no one renamed any columns.

For a simple report, do the following steps:
- Select Power BI Visualization Table.
- Add columns "WorkItemID" to Values.
- Right-click "WorkItemID" and select Don't summarize.
- Add column "Title" to Values.
- Add column "Link.TargetWorkItem.WorkItemID" to Values.
- Right-click "Link.TargetWorkItem.WorkItemID" and select Don't summarize.
- Add column "Link.TargetWorkItem.Title" to Values.
- In Filters, for the column "Link.TargetWorkItem.WorkItemID", select Show items when value and select the option is not blank. Then select Apply Filter.
- This action filters out any work items that don't have a link.
The resulting example report is shown in the following image.
Note
Note how work item 233464 is represented by two rows, one for each linked work item.

Pull in data from multiple teams
Oftentimes, you want to aggregate and compare data from multiple teams. If you are pulling in items from multiple teams, consider adding a Team slicer to your report. A Team slicer allows you to filter the existing report by Team Name.
Additional queries
You can use the following additional queries to create different but similar reports using the same steps defined previously in this article.
Filter by Teams, rather than Area Path
The following query is the same as the one used previously in this article, except it filters by Team Name rather than Area Path.
You can paste the Power BI query listed below directly into the Get Data->Blank Query window. For more information, review Overview of sample reports using OData queries.
let
Source = OData.Feed ("https://analytics.dev.azure.com/{organization}/{project}/_odata/v3.0-preview/WorkItems?"
&"$filter=WorkItemType eq 'User Story' "
&"and State ne 'Closed' "
&"and (Teams/any(x:x/TeamName eq '{teamname}) or Teams/any(x:x/TeamName eq '{teamname}) or Teams/any(x:x/TeamName eq '{teamname}) "
&"&$select=WorkItemId,Title,WorkItemType,State,Priority,Severity,TagNames,AreaSK "
&"&$expand=AssignedTo($select=UserName),Iteration($select=IterationPath),Area($select=AreaPath), "
&"Links( "
&"$filter=LinkTypeName eq 'Related' "
&"and TargetWorkItem/WorkItemType eq 'User Story'; "
&"$select=LinkTypeName; "
&"$expand=TargetWorkItem($select=WorkItemType,WorkItemId,Title,State) "
&") "
,null, [Implementation="2.0",OmitValues = ODataOmitValues.Nulls,ODataVersion = 4])
in
Source
Return bugs with a Duplicate link to another bug
You can paste the Power BI query listed below directly into the Get Data->Blank Query window. For more information, review Overview of sample reports using OData queries.
let
Source = OData.Feed ("https://analytics.dev.azure.com/{organization}/{project}/_odata/v3.0-preview/WorkItems?"
&"$filter=WorkItemType eq 'Bug' "
&"and State ne 'Closed' "
&"and startswith(Area/AreaPath,'{areapath}') "
&"and Links/any(x:x/LinkTypeName eq 'Duplicate' and x/TargetWorkItem/WorkItemType eq 'Bug') "
&"&$select=WorkItemId,Title,WorkItemType,State,Priority,Severity,TagNames "
&"&$expand=AssignedTo($select=UserName),Iteration($select=IterationPath),Area($select=AreaPath), "
&"Links( "
&"$filter=LinkTypeName eq 'Duplicate' "
&"and TargetWorkItem/WorkItemType eq 'Bug'; "
&"$select=LinkTypeName; "
&"$expand=TargetWorkItem($select=WorkItemType,WorkItemId,Title,State) "
&") "
,null, [Implementation="2.0",OmitValues = ODataOmitValues.Nulls,ODataVersion = 4])
in
Source
Return bugs that don't have a Duplicate link to another bug
You can paste the Power BI query listed below directly into the Get Data->Blank Query window. For more information, review Overview of sample reports using OData queries.
let
Source = OData.Feed ("https://analytics.dev.azure.com/{organization}/{project}/_odata/v3.0-preview/WorkItems?"
&"$filter=WorkItemType eq 'Bug' "
&"and State ne 'Closed' "
&"and startswith(Area/AreaPath,'{areapath}') "
&"and not (Links/any(x:x/LinkTypeName eq 'Duplicate' and x/TargetWorkItem/WorkItemType eq 'Bug')) "
&"&$select=WorkItemId,Title,WorkItemType,State,Priority,Severity,TagNames "
&"&$expand=AssignedTo($select=UserName),Iteration($select=IterationPath),Area($select=AreaPath) "
,null, [Implementation="2.0",OmitValues = ODataOmitValues.Nulls,ODataVersion = 4])
in
Source
Full list of sample reports
- Open bugs
- Bug trend
- Rollup
- Feature progress
- Work items and direct links
- Release burndown
- Sprint burndown
- Cumulative Flow Diagram (CFD)
- Lead/Cycle Time
Related articles
Feedback
Issottometti u ara feedback għal