ActiveReports 8 > ActiveReports User Guide > Samples and Walkthroughs > Walkthroughs > Page Report Walkthroughs > Data > Expressions in Reports |
You can use expressions in the control's properties to calculate values. You can also use expressions to concatenate fields, to concatenate strings with fields, to aggregate data, to set formatting based on field values, to show or hide other controls based on field values and even to display a graphical representation of the data. This walkthrough illustrates the how to use expressions to achieve different effects.
The walkthrough is split into the following activities:
![]() |
Note: This walkthrough uses the MovieProduct table from the Reels database. By default, in ActiveReports, the Reels.mdb file is located in the [User Documents folder]\ComponentOne Samples\ActiveReports 8\Data folder. |
When you complete this walkthrough you get a layout that looks similar to the following at design time and at runtime.
![]() |
![]() |
To add an ActiveReport to the Visual Studio project
See Adding an ActiveReport to a Project for information on adding different report layouts.
To connect the report to a data source
To add a dataset
SQL Query |
Copy Code
|
---|---|
SELECT * FROM DVDStock |
To create a layout for the report
Table Column | Width |
---|---|
TableColumn1 | 3.5in |
TableColumn2 | 1in |
TableColumn3 | 1in |
TableColumn4 | 1in |
Data Field | Column Name |
---|---|
TableColumn1 | Title |
TableColumn2 | StorePrice |
TableColumn3 | InStock |
To add a field expression to a text box to multiply two field values
= Fields!InStock.Value* Fields!StorePrice.Value
To add an Immediate If expression to show or hide a report control
=iif(Fields!InStock.Value=0, True, False)
To add a Data Visualization expression to display data graphically
The ColorScale3 visualizer function displays a range of colors to indicate minimum, average, and maximum values in the data. See the Data Visualizers topic for further information.
Select the cell in the detail row under the In Stock label and in the Properties window, set the BackgroundColor property to the following expression: =ColorScale3(Fields!InStock.Value, 0, Avg(Fields!InStock.Value), Max(Fields!InStock.Value), "Red", "Yellow", "Green")
![]() |
Note: The parameters of the ColorScale3 function evaluate to Value, Minimum, Average, Maximum, StartColor, MiddleColor and EndColor. Note that aggregate functions (Avg and Max) are used within the ColorScale3 function. See Functions for details on these and other aggregate functions. |
To view the report
OR