The requested page is not available for the requested platform. You are viewing the content for Default platform.

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

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

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

ParameterCalcFieldTutorial_SampleGrid

Suppose that you want to create a calculated field that returns different values depending on the selected parameter value. In the example, the calculated field will return TRUE or FALSE depending on whether the average discount exceeds the selected parameter value. To do this, perform the following steps.

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 will be 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.
  • Finally, change the parameter Name to discountValue.

Click OK to create the dashboard parameter.

Pass the Parameter to a Calculated Field's Expression

To pass the created parameter to a calculated field's expression, create a new calculated field by clicking 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

Note that 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 and drop the IsGreater field 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 placed within 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 will be recalculated.

See Also