Azure DevOps template variables
Use template variables to create dynamic, reusable dashboards that let you switch between projects, repositories, and other resources without editing individual queries.
Before you begin
Supported variable types
Create a query variable
To create a query variable:
- Navigate to Dashboard settings > Variables.
- Click Add variable.
- Select Query as the variable type.
- Select the Azure DevOps data source.
- Choose a Query Type from the drop-down.
Query variable types
The Azure DevOps data source supports the following query variable types:
Use variables in queries
Template variables work in two ways within the query editor.
Drop-down pickers
The Project and Repository drop-downs automatically include dashboard template variables as selectable options. When you create a variable of type Projects or Repositories, it appears in the drop-down list alongside regular values.
Text filter fields
You can also use the $variableName syntax in any text input field across all query types. For example, you can use a variable in the Branch field to dynamically filter builds, or in the Creator Id field to filter pull requests by a variable-controlled identity.
Examples
The following examples show common patterns for using template variables with the Azure DevOps data source.
Switch between projects
Create a variable that lets dashboard viewers select which project to display data for:
- Create a Projects query variable named
project. - In a query, select
$projectfrom the Project drop-down. - Use the dashboard variable selector to switch between projects, and all panels using that variable update automatically.
Chain project and repository variables
Create cascading variables where the repository list updates based on the selected project:
- Create a Projects query variable named
project. - Create a Repositories query variable named
repo. - In the
repovariable settings, select$projectfrom the Project drop-down to filter repositories to the selected project. - In your queries, select
$projectfor the Project and$repofor the Repository.
When a user changes the project, the repository variable automatically refreshes to show only repositories in that project.
Use a variable in a filter field
Use variables in text filter fields to create flexible, reusable queries:
- Create a Custom variable named
branchwith values likerefs/heads/mainandrefs/heads/develop. - In a Builds query, type
$branchin the Branch field. - Dashboard viewers can switch between branches to see builds for each one.
This pattern works in any text input field, including Creator Id, Source Ref, Requested For, Source branch, and others.
Known limitations
- Template variables don’t support multi-select. Only single selection is supported.
- Regex filtering by project or repository name isn’t supported in the variable editor.


