# Use Parameters

***

### Default Parameter

By default a newly created dashboard will contain the **Time Range** parameter, which lets the user choose a default timerange for the data that appears in the dashboard.&#x20;

By clicking on the Parameters button in the top menu, you are able to edit the Time range parameter by clicking the pen icon.

<figure><img src="https://570593659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYMGRODsc2QD3N3wmfwTl%2Fuploads%2FnfqqAUSFX6IGAprCXrkR%2Fimage.png?alt=media&#x26;token=f27c71a4-904a-4db9-83cf-f4313bbccc65" alt=""><figcaption><p>Click Parameters then click edit on the Time range parameter</p></figcaption></figure>

This should open up the Edit Parameter dialog, en lets you view the details of the Time range parameter.

<figure><img src="https://570593659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYMGRODsc2QD3N3wmfwTl%2Fuploads%2FEpzeV7sI2dOSO83vpI6n%2Fimage.png?alt=media&#x26;token=bc1f38d9-05f6-4647-bb69-0d49292ad785" alt="" width="217"><figcaption><p>The Edit Parameter dialog</p></figcaption></figure>

* The ***label*** is the name of the parameter that is used in the dashboard
* The ***Parameter type*** can be set to either Single selection, Mutliple select, Free text, Time range and Data source.
* The ***starttime*** and ***endtime varable names***, are the variable name(s) that can be used in dashboard tiles/queries to use the selected value of the parameter.
* The ***Show on pages*** lets you set which pages of the dashboard should include the parameter.
* The ***defult value*** is the value that the parameter should have when first initialized.

### Create a custom Parameter

Parameters can be used in Dashboards to filter on data that is being visualized. Using parameters also significantly improve dashboard rendering performance, because values are filtered as early as possible in the query. Filtering is enabled when the parameter is included in the query associated with a tile.&#x20;

For more detailed information about how to set up and use different kinds of parameters see [Use parameters in dashboards](https://learn.microsoft.com/en-us/azure/data-explorer/dashboard-parameters).

1. Click the **Parameters** button in the top of the dashboard.
2. Click the **Add** button.

<figure><img src="https://570593659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYMGRODsc2QD3N3wmfwTl%2Fuploads%2F0iBBeZbjFEuzEnmxuSM4%2Fimage.png?alt=media&#x26;token=81dcadc2-da94-45f4-81c2-50008d87e34f" alt=""><figcaption><p>Add a new Parameter to a dashboard</p></figcaption></figure>

4. You must specify a Name for the **Label** (Will be shown in Dashboard selection)
5. Give it an optional description and set a **Variable Name** that can be used in your queries as a filter
6. Set it to be shown on the currently selected **Page**
7. Select **Query** and click **Edit Query** to specify the Query

Then add the following Query into the dialog:

```kusto
Measurements
| where StartTimestamp between (_startTime .. _endTime)
| distinct HierarchicalName
| order by HierarchicalName asc
```

<figure><img src="https://570593659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYMGRODsc2QD3N3wmfwTl%2Fuploads%2F2MEqBz6Z6Gk0qkli4Nxg%2Fimage.png?alt=media&#x26;token=6847fbd5-0261-43df-a863-dd73f7b16fe8" alt=""><figcaption><p>Adding a Query to select Parameters.</p></figcaption></figure>

8. In the **Add Query Dialog** you can specify your **Query**.
9. In the example above, we are using the Dashboard 's **Time range** filter to select the HierarchicalName of all available Measurements within the Period, then we order them in ascending alphabetically.
10. Click the **Add** button
11. Make sure to set the **Value column** in the Add Parameter Dialog is set to the HierarchicalName (The column name of the Query just specified)

<figure><img src="https://570593659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYMGRODsc2QD3N3wmfwTl%2Fuploads%2FAgTkJCqUKmDo9x03RQZT%2Fimage.png?alt=media&#x26;token=5df0f962-cf3d-4fa5-a8b8-af0a2976950a" alt=""><figcaption><p>The parameter should appear in the top of the dashboard</p></figcaption></figure>

***

### Use parameter to filter a Tile

You can use the Parameter that the user has selcted to filter the data that is shown in Tiles.&#x20;

1. Add a new Tile to the dashboard by clicking **Add/Add tile**
2. Add the following Query into the query textbox:

```kusto
Measurements
| where StartTimestamp between (_startTime .. _endTime)
| where HierarchicalName has _hierarchicalName
| order by StartTimestamp asc
| limit 5000
```

Notice the use of the parameters **\_*****startTime**, **\_*****endTime** and **\_hierarchicalName** in the query, to narrow down the search.

<figure><img src="https://570593659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYMGRODsc2QD3N3wmfwTl%2Fuploads%2FIkt3xNY87HZz0Z3cGy4w%2Fimage.png?alt=media&#x26;token=d7de2b8a-d9ee-4c2f-a156-b3bc9f04d08c" alt=""><figcaption><p>Using parameters to filter what data to load</p></figcaption></figure>

The Query will load all Measurements from the Measurements table that has a StartTimestamp in the selecteed Time range and has the selected Tag name (HierarchicalName), it then orders the Measurements by StartTimestamp and then limits the query to only load 5000 data points.

For more details on Parameters please see Microsoft Dooumentation and the [Azure Data Explorer Parameters](https://learn.microsoft.com/en-us/azure/data-explorer/dashboard-parameters).

### Visualize filtered data in a Tile

1. You can add visualization by clicking the **Add visual** button. Give the Tile a name.
2. Select the **Line chart** in the Visual type dropdown.
3. Make sure you select the **Value** of the measurements for the Y column (y-axis), and the **StartTimestamp** as the X columns (x-axis).&#x20;

<figure><img src="https://570593659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYMGRODsc2QD3N3wmfwTl%2Fuploads%2FGN6MHVuTkRMqyn7qYIuK%2Fimage.png?alt=media&#x26;token=7e8e7bca-ede2-4f20-a6c2-84669eeca611" alt=""><figcaption><p>Visualize the filtered values for the selected Tag</p></figcaption></figure>

If you have configured it correctly you should see a visualization similar to the above screenshot.

{% hint style="info" %}
The Visualization Type (Line chart) is only suitable for Measurements of Type **Analog** or **Digital**, since the Value type is a Real.&#x20;

For **String** measurements you can use a Table to visualize the data.
{% endhint %}

Having configured the Visual you can click the **Apply changes** then click **Save** to save the changes of the dashboard.

<figure><img src="https://570593659-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FYMGRODsc2QD3N3wmfwTl%2Fuploads%2FAcS48hZo3opNpacCqNwc%2Fimage.png?alt=media&#x26;token=ffb48bbd-9a95-451f-9d8f-fb04cd18a7ad" alt=""><figcaption><p>Dashboard using parameters</p></figcaption></figure>

On the dashboard page - try and select different Time range and different Tag names, and watch how the Tile automatically fetches the filtered data and visualizes it.

For more details on customizing visuals, please see Microsoft Dooumentation [Azure Data Explorer Customize dashboard visuals](https://learn.microsoft.com/en-us/azure/data-explorer/dashboard-customize-visuals).
