Update Variable
In this article
Use this action to change the value of a variable in the dashboard.
Note
It is impossible to update input values and system variables using this click action.
Usage Example
As an example, consider a dashboard that displays a product price after applying a discount.
- Two Input Value variables are added to the dashboard: Discount and Discounted Price. The default value for Discount is 10, and for Discounted Price it is 0.
- Three widgets are added to the view: Parameter, Text, and Table.
- The Parameter widget displays the value of the Discount variable.
- The Text widget displays the value of the Discounted Price variable.
- The table shows product names and their prices. The Unit Price dimension has the Update Variable click action assigned.
- In the click action settings, the Discounted Price variable is selected.
- The Discounted Price variable is updated using the formula:
"product"."Unit Price" * (1 - ${Discount (%)}/100). - To trigger the click action immediately upon clicking a product price, table filtering is disabled.
- Configuration is complete. Publish the dashboard. Set an arbitrary discount size, for example, 25%, and click any product price to execute the click action.
- The Discounted Price variable updates.
Click Action in YAML
To add a click action (UPDATE_VARIABLE), use the keys listed in the table. Specify these keys within the onClick block. Keys for the onClick block are described on the page Click Actions.
| Key | Type | Definition |
|---|---|---|
| variables | — | List of variables |
| name | string | Variable name |
| inputMethod | enum | Input Method |
Use the name and inputMethod keys inside the variables block. Example:
onClick:
- type: UPDATE_VARIABLE
name: Update Variable
variables:
- inputMethod: FORMULA
formula: '"product"."Unit Price" * (1 - ${Discount (%)}/100)'
name: Discounted Price
Was the article helpful?
Yes
No