Expression
- 2 minutes to read
An Expression format condition allows you to use complex conditions to apply formatting.
- Create a Format Rule in the WinForms Designer
- Create a Format Rule in the Web Dashboard
- Create a Format Rule in Code
Create a Format Rule in the WinForms Designer
To format values according to the Expression condition, click the menu button of the required data item and select Add Format Rule | Expression.
This invokes the Expression dialog that allows you to specify the required expression. For instance, the following image displays a Grid dashboard item whose rows are filled in green if the Extended Price/Quantity values are greater than 150 000 and 7 500, respectively.
You can pass static values when creating conditions or pass a dashboard parameter to apply conditional formatting dynamically. To learn more, see Pass Parameter Values.
Create a Format Rule in the Web Dashboard
In the Conditional Formatting section, click the plus button to add a new format rule:
Select the data item you want to format and set the condition type to Expression:
In the opened settings click the Edit… button to specify a condition:
This invokes the Expression dialog that allows you to specify the required expression. For instance, the following image displays a Grid dashboard item whose rows are filled in green if the Extended Price/Quantity values are greater than 150 000 and 7 500, respectively.
You can pass static values when creating conditions or pass a dashboard parameter to apply conditional formatting dynamically. See Pass Parameter Values for more information.
Create a Format Rule in Code
To create the Expression format condition in code, create a FormatConditionExpression class instance and specify the following settings.
- Specify the expression that defines the comparison logic by setting the FormatConditionExpression.Expression property. Use the DataItem.UniqueId property to refer to the required dimensions/measures. See Expression Constants, Operators, and Functions to learn the expression syntax.
- Specify the required style settings applied to target elements using the FormatConditionStyleBase.StyleSettings property. You can change the color of dashboard item elements, font settings (AppearanceSettings) or add predefined icons (IconSettings).
Assign the resulting FormatConditionExpression object to the DashboardItemFormatRule.Condition property.