Using Dashboard Parameter in Kusto Query
Using Dashboard Parameter in Kusto Query
or Azure Data Explorer dashboards), you can use parameters to make queries dynamic.
For **Boolean parameters**, the process involves defining the parameter in the
dashboard and referencing it in your Kusto Query Language (KQL) query.
---
---
You reference the parameter using curly braces `{}` in your query. For a parameter
named `isActive`, you'd write:
```kql
let isActive = {isActive}; // This pulls the parameter value from the dashboard
MyTable
| where Active == isActive
```
- **Explanation:**
- `let isActive = {isActive};` assigns the parameter's value to a KQL variable.
- The `where` clause filters the data based on the Boolean value.
---
```kql
let isActive = tobool({isActive});
MyTable
| where Active == isActive
```
---
If you want the filter to be optional (i.e., apply the filter only when `isActive =
true`):
```kql
let isActive = tobool({isActive});
MyTable
| where (isActive == false or Active == true)
```
- **Logic:**
- When `isActive = false`, the filter doesn't restrict anything.
- When `isActive = true`, it filters for `Active == true`.
---
### ⚡ **Example**
```kql
let showErrors = tobool({ShowErrors});
Logs
| where (showErrors == false or Severity == "Error")
| project Timestamp, Message, Severity
```
---
---
Let me know if you'd like more examples or if you're facing specific issues! 🚀