Skip to main content
A newer version of this page is available. .

How to: Pass a Dashboard Parameter to a Calculated Field's Expression

  • 3 minutes to read

This tutorial demonstrates how to pass a dashboard parameter to a calculated field’s expression in the WinForms Dashboard Designer.

The DevExpress Dashboard is connected to the SalesPerson view of the Northwind database. The Grid dashboard item is bound to the CategoryName and Discount fields.

ParameterCalcFieldTutorial_SampleGrid

For example, you need to create a calculated field that returns different values depending on the selected parameter value. In the example, the calculated field returns TRUE or FALSE depending on whether the average discount exceeds the selected parameter value. Follow the steps below to do this:

Create a Parameter

To create a dashboard parameter, click the Parameters button in the Home ribbon tab.

Parameters_AddParameterButton_Ribbon

In the invoked dialog, click Add to create a new parameter…

ParameterCalcFieldTutorial_SpecifyParameterSettings

…and specify its settings in the following way.

  • Specify the Description that is displayed in the Dashboard Parameters dialog for this parameter.
  • Set Look-Up Settings to Static List and click the ellipsis button next to Values. In the invoked Parameter Values dialog, specify possible parameter values (0.01, 0.05 and 0.10)…

    ParameterCalcFieldTutorial_PossibleParameterValues

    …and click OK.

  • Change the parameter’s Type to Number (double-precision floating-point). Then, specify the default parameter Value as 0.05.
  • Change the parameter Name to discountValue.

Click OK to create the dashboard parameter.

Pass the Parameter to a Calculated Field’s Expression

Create a new calculated field to pass the created parameter to a calculated field’s expression. :lick the Add Calculated Field button in the Data Source ribbon tab.

ParameterCalcFieldTutorial_AddCalculatedFieldRibbon

In the invoked Expression Editor, specify the following expression: Iif(Avg([Discount]) >= [discountValue], 'TRUE', 'FALSE')

ParameterCalcFieldTutorial_ExpressionEditor

Note

This expression contains the following objects.

  • The Iif logical function returns either TruePart or FalsePart, depending on the evaluation of the Boolean Expression. You can find this function in Functions.
  • The Avg aggregate function returns the average of all the values in the expression. You can find this function in Aggregate Functions.
  • The Discount data source field can be found in Fields.
  • Finally, the discountValue parameter can be found in Parameters.

Click OK to create a calculated field. Then, right-click the created field, select Rename and change the name of this field to IsGreater.

ParameterCalcFieldTutorial_RenameCalculatedField

Drag the IsGreater field and drop it to the Columns section of the Grid dashboard item and see the result:

ParameterCalcFieldTutorial_ResultingGrid

You can see that the column corresponding to the IsGreated field returns TRUE or FALSE depending on whether the discount value is greater than 0.05 (or 5%). You can click the Parameters button in the dashboard title to change the current parameter value in the Dashboard Parameters dialog.

ParameterCalcFieldTutorial_DashboardParametersDialog

In this case, values returned by the IsGreater field are recalculated.

See Also