Calling an input value from a widget
For either type of input to work as a filter for a widget, the widget's query must reference the required input through a script. You must place the input script in the place the query references the values you want to filter by. Depending on the data to be entered in the input, you can use the following types of expressions:Â
Query script | Sample widget query | Result |
---|---|---|
Use this expression as a placeholder for whole queries, for example:
| query( Input0.value) | Just enter the required query in the input with ID Input0 and the widget will display the query results immediately. |
The
| query( from demo.ecommerce.data where method=$Input0.value) | The widget will represent all the events where the method is equal to the value entered in the input with ID Input0. In this case, we must use |
The
| query( from $*Select0.value group every $*Select1.value) | The widget will represent all the events from the data table entered in the input Select0 grouped by the period specified in the input Select1. In this case, we must use |
All widget and input ID values are assigned automatically and can be read in the Data settings of the widget or input element.
Examples
You can use multiple inputs simultaneously to generate a widget able to display different sets of data with just a few clicks. Below are some examples that may help you better understand the potential of inputs.
Example 1
Use the following query in a table widget to create a dynamic table that allows you to specify the source data table, the grouping period and the grouping key.
|
The table is linked to three different Select-type inputs populated with the following values:
Select0
|
Select1
|
Select2
|
The following capture shows the table after selecting demo.ecommerce.data as source table, 1s as grouping time and statusCode as key column for the grouping.
Example 2
Feed a column widget with the following query to display the count of status codes greater than a specified value and grouped by a period selected from a list of values.
|
The Select-type input is populated with the following values:
|
The following capture shows the column widget after selecting 5m as grouping time and entering 400 in the free-text input, so that only status codes greater than 400 are shown. You must select the count field as the Y-axis value and add the statusCode column as a series in the Visual settings of the column widget.