Use parameters in Azure Data Explorer dashboards
Parameters are used as building blocks for dashboard filters in Azure Data Explorer dashboards. They're managed in the dashboard scope, and can be added to queries to filter the data presented by the underlying visual. A query can use one or more parameters.
This document describes the creation and use of parameters and linked filters in Azure Data Explorer dashboards. Parameters can be used to slice and dice dashboard visuals either directly by selecting parameter values in the filter bar or by using cross-filters.
Note
Parameter management is available in Editing mode to dashboard editors.
Prerequisites
Visualize data with Azure Data Explorer dashboards
View parameters list
Select the Parameters button at the top of the dashboard to view the list of all dashboard parameters.
Create a parameter
To create a parameter:
- Select the Parameters button at the top of the dashboard.
- Select the + New parameter button at the top of the right pane.
- Fill in the relevant properties for your parameter.
Properties
In the Add parameter pane, configure the following properties.
Field | Description |
---|---|
Label | The name of the parameter shown on the dashboard or the edit card. |
Parameter type | One of the following parameters:
|
Variable name | The name of the parameter to be used in the query. |
Data type | The data type of the parameter values. |
Show on pages | Select the pages where this parameter will be displayed. The Select all option shows the parameter on all pages. |
Source | The source of the parameter values:
|
Default value | The default value of the filter. The filter will start always with the default value upon initial rendering of the dashboard. |
Add a "Select all" value | Applicable only to single selection and multiple selection parameter types. Used to retrieve data for all the parameter values. This value should be built into the query to provide the functionality. See Use the multiple-selection query-based parameter for more examples on building such queries. |
Manage parameters in parameter card
After selecting Parameters from the top bar, you can view the list of existing parameters. In each parameter card, you can select the pencil widget to edit the parameter, or select the More [...] menu to Duplicate, Delete, or move the parameter.
The following indicators can be viewed in the parameter card:
- Parameter display name
- Variable names
- Number of queries in which the parameter was used
- Pages the parameter is pinned to
The parameter cards can be ordered by drag and drop or by using the Move to > option and selecting the new location.
Use parameters in your query
A parameter must be used in the query to make the filter applicable for that query visual. Once defined, you can see the parameters in the Query page > filter top bar and in the query intellisense.
Note
If the parameter isn't used in the query, the filter remains inactive. Once the parameter is added to the query, the filter becomes active.
Use different parameter types
Several dashboard parameter types are supported. The following examples describe how to use parameters in a query for various parameter types.
Use the default Time range parameter
Every dashboard has a Time range parameter by default. It shows up on the dashboard as a filter only when used in a query. Use the parameter keywords _startTime
and _endTime
to use the default time range parameter in a query as seen in the following example:
EventsAll
| where Repo.name has 'Microsoft'
| where CreatedAt between (_startTime.._endTime)
| summarize TotalEvents = count() by RepoName=tostring(Repo.name)
| top 5 by TotalEvents
Once saved, the time range filter shows up on the dashboard. Now it can be used to filter the data on the card. You can filter your dashboard by selecting from the drop-down: Time range (last x minutes/hours/days) or a Custom time range.
Use the single selection fixed value parameter
Fixed value parameters are based on predefined values specified by the user. The following example shows you how to create a single selection fixed value parameter.
Create a fixed value parameter
Select Parameters to open the Parameters pane and select New parameter.
Fill in the details as follows:
- Label: Company
- Parameter type: Single selection
- Variable name:
_company
- Data type: String
- Pin as dashboard filter: checked
- Source: Fixed values
In this example, use the following values:
Value Parameter display name google/ Google microsoft/ Microsoft facebook/ Facebook aws/ AWS uber/ Uber - Add a Select all value: Unchecked
- Default value: Microsoft
Select Done to create the parameter.
The parameter can be seen in the Parameters side pane, but aren't currently being used in any visuals.
Use the parameter
Run a sample query using the new Company parameter by using the
_company
variable name:EventsAll | where CreatedAt > ago(7d) | where Type == "WatchEvent" | where Repo.name has _company | summarize WatchEvents=count() by RepoName = tolower(tostring(Repo.name)) | top 5 by WatchEvents
The new parameter shows up in the parameter list at the top of the dashboard.
Select different values to update the visuals.
Use the multiple-selection fixed-value parameters
Fixed value parameters are based on predefined values specified by the user. The following example shows you how to create and use a multiple-selection fixed-value parameter.
Create the parameters
Select Parameters to open the Parameters pane and select New parameter.
Fill in the details as mentioned in Use the single selection fixed value parameter with the following changes:
- Label: Companies
- Parameter type: Multiple selection
- Variable name:
_companies
Select Done to create the parameter.
The new parameters can be seen in the Parameters side pane, but aren't currently being used in any visuals.
Use the parameters
Run a sample query using the new companies parameter by using the
_companies
variable.EventsAll | where CreatedAt > ago(7d) | extend RepoName = tostring(Repo.name) | where Type == "WatchEvent" | where RepoName has_any (_companies) | summarize WatchEvents=count() by RepoName | top 5 by WatchEvents
The new parameter shows up in the parameter list at the top of the dashboard.
Select one or more different values to update the visuals.
Use the single selection query-based parameter
Query-based parameter values are retrieved during dashboard loading by executing the parameter query. The following example shows you how to create and use a single selection query-based parameter.
Create a single selection parameter
Select Parameters to open the Parameters pane and select New parameter.
Fill in the details as mentioned in Use the single selection fixed value parameter with the following changes:
- Label: Event
- Variable name:
_event
- Source: Query
- Data source: GitHub
- Select Add query and enter the following query. Select Done.
EventsAll | distinct Type | order by Type asc
- Value: Type
- Display name: Type
- Default value: WatchEvent
Select Done to create the parameter.
Use a parameter in the query
The following sample query with the new Event parameter uses the
_event
variable:EventsAll | where Type has (_event) | summarize count() by Type, bin(CreatedAt,7d)
The new parameter shows up in the parameter list at the top of the dashboard.
Select different values to update the visuals.
Use the multiple-selection query-based parameter
Query-based parameter values are derived at dashboard load time by executing the user specified query. The following example shows how to can create a multiple-selection query-based parameter:
Create a query-based parameter
Select Parameters to open the Parameters pane and select + New parameter.
Fill in the details as mentioned in Use the single selection fixed value parameter with the following changes:
- Label: Events
- Parameter type: Multiple selection
- Variable name:
_events
Select Done to create the parameter.
Use the parameter in a query
The following sample query uses the new Events parameter by using the
_events
variable.EventsAll | where Type in (_event) or isempty(_events) | summarize count() by Type, bin(CreatedAt,7d)
Note
This sample uses the Select All option by checking for empty values with the
isempty()
function.The new parameter shows up in the parameter list at the top of the dashboard.
Select one or more different values to update the visuals.
Use the free text parameter
Free text parameters don't contain any values. They allow you to introduce your own value.
Create a free text parameter
- Select Parameters to open the Parameters pane and select + New parameter.
- Fill in the details as follows:
- Label: Company
- Parameter type: Free text
- Variable name: _company
- Data type: String
- Pin as dashboard filter: checked
- Default value: No default value
Use the parameter in a query
Run a sample query using the new Company parameter by using the
_company
variable name:EventsAll | where CreatedAt > ago(7d) | where Type == "WatchEvent" | where Repo.name has _company | summarize WatchEvents=count() by RepoName = tolower(tostring(Repo.name)) | top 5 by WatchEvents
Use the data source parameter
Once you have added data sources to your dashboard, you can create a parameter that selects one or more of the available data sources. This parameter can be used in tiles and other parameters.
Create a data source parameter
Select Parameters to open the Parameters pane and select + New parameter.
Fill in the details as follows:
- Label: Cluster
- Parameter type: Data source
- Show on pages: Select all
- Values: Select all
- Default value: Samples
Select Done.
The new parameter is now visible in the parameter list at the top of the dashboard.
Use the parameter in a query
Navigate to the query of a new or existing tile.
In Source, select the name of your new parameter under Data source parameters. For the above-created parameter, select Cluster
Select Apply changes.
Use the Cluster parameter to change the data source for this connected query.
Use cross-filters as dashboard parameters
Cross-filters allow you to select a value in one visual and all dashboard visuals, such as line or scatter charts, are filtered to only show related data. Using cross-filters achieves the same result as selecting the equivalent value for the parameter in the parameter list at the top of the dashboard.
Define cross-filters
To create a cross-filter, you must turn it on in the visual and then specify the parameter that is used to filter the data.
Edit the dashboard, and then edit the visual where you want to add cross-filters.
Select Visual.
In the right pane, select Interactions, and then turn on cross-filters.
Specify both the column that will be used to provide the value and a parameter used to filter the visuals' query.
Important
The column and parameter must be of the same data type.
Interact with your data using cross-filter
Once the cross-filter is defined, you can use it to interact with your data. In visuals where you've defined cross-filters, you can select data points and use their values to filter the current dashboard page. For table visuals, select data points by right-clicking on the relevant cell and then in the context menu, select Cross-filter.
You can reset the cross-filter by selecting Reset at the top of the visual where it was selected.
Use drillthroughs as dashboard parameters
With drillthrough, you can select a value in a visual and use it to filter the visuals in a target page in the same dashboard. When the target page opens, the value is preselected in the relevant filters. The visuals on the page, such as line or scatter charts, are filtered to only show related data.
Define a drillthrough
To create a drillthrough, you must first turn it on in the visual and then add one or more drillthroughs as required.
Edit the dashboard.
Edit the visual where you want to add a drillthrough. Make sure that the Visual tab is selected.
In the right pane, select Interactions, then turn on drillthrough.
Under Drillthrough, select Create new, and specify the following information. Optionally select Add another pair to add multiple parameters for a target page. Repeat this step to add drillthroughs to other pages in the current dashboard using different parameters.
Field Description Destination page One or more target pages to drill through to using the defined parameters. Column The query result's column to use as the value for a parameter in the target page. Parameter The parameter used to filter visuals in the target page using the column value. Notes Optional short description. Important
Column and parameter pairs must be of the same data type.
Interact with your data using drillthroughs
Once drillthroughs are defined, you can use them to interact with your data. To do so, in visuals or tables where you've defined a drillthrough, right-click on a data point, and then select Drill through to > destination page. The values from the data point will be used as the parameters to filter the visuals on the target page.
To return to the source page, in the top-right of the destination page, select Back. All filters assigned by the drillthrough will be reset.
Use filter search for single and multiple selection filters
In single and multiple selection filters, type the value that you want. The filter search will present only the recently retrieved values that match the search term.