Using Base Queries in Kusto dashboard
Using Base Queries in Kusto dashboard
dashboards. Base queries allow you to define a common dataset that can be
referenced by multiple tiles in the dashboard, ensuring consistency and simplifying
maintenance. Here’s a step-by-step guide on how to use base queries in a Kusto
Explorer dashboard:
```kql
let BaseData = MyTable
| where Timestamp >= datetime(2023-01-01) and Timestamp <= datetime(2023-01-31)
| project Timestamp, Value;
BaseData
```
**Instructions:**
1. Write your base query in Kusto Explorer.
2. Highlight the query and right-click to bring up the context menu.
3. Select "Save As Base Query" or similar option.
4. Give your base query a meaningful name, such as `BaseData`.
**Instructions:**
1. Click `New Dashboard` to create a new dashboard or select an existing one to
edit.
```kql
let BaseData = cluster('mycluster').database('mydatabase').BaseData;
BaseData
| summarize TotalValue = sum(Value) by bin(Timestamp, 1d)
| project Timestamp, TotalValue
```
**Instructions:**
1. In the dashboard editor, add a new tile.
2. Select the type of visualization you want (e.g., table, chart).
3. Insert a query that references your base query.
4. Use the base query by referencing its name as shown in the example.
```kql
let BaseData = MyTable
| where Timestamp >= datetime({startDate}) and Timestamp <= datetime({endDate})
| project Timestamp, Value;
BaseData
```
**Instructions:**
1. Define `startDate` and `endDate` parameters in the Parameters tab.
2. Bind these parameters to Date Picker controls in the dashboard.
**Instructions:**
1. Save the dashboard.
2. Use the input controls to select different parameter values (e.g., date ranges).
3. Verify that the query results in the tiles update accordingly based on the
selected parameters.
### Summary
This approach allows you to maintain consistency across multiple tiles and
simplifies the management of your dashboard by using a common base query.