You can use an expression to set the value of a control in the report, or set conditions under which certain styles apply. You can set expressions through the Expression Editor dialog while setting values in the properties window. The editor allows you to choose from a number of fields available to the report as well as to a particular property. You can access the Expression Editor by selecting nearly any property of a control and choosing <Expression...> from the drop-down list.
All expressions begin with an equal to sign (=). Even the expression for a field value for a TextBox is set as follows:
=Fields!LastName.Value
.
While building an expression, you can directly add the entire expression or part of it in the Expression pane of the Expression Editor. Then use the Insert or Append buttons to create a complete expression.
You can concatenate fields with strings and with other fields. For e.g., use the following expression to get a result like "Customer Name: Bossert, Lewis":
="Customer Name: " & Fields!LastName.Value & "," & Fields!FirstName.Value
You can use expressions in properties like Color, Font, Border etc. on specific field values based on a condition, to highlight a part of data. The formula for conditional formatting is:
=iif( Fields!YourFieldName.Value operator "Value to compare", "If condition is met, use this value.", "If not, use this one."
For e.g., if you enter the following expression in the Font > FontWeight property of a textbox that displays names of people, you get the name "Denise" in bold.
=iif(Fields!FirstName.Value = "Denise", "Bold", "Normal")
Similarly, if you enter the following expression in the Background >Color property of a textbox in a table, then you get alternating 'Transparent' and 'LightGray' colored textboxes in the rows of the table.
=iif(RowNumber(Nothing) Mod 2, "Transparent", "LightGray")
You can use a number of aggregate and other functions in your expressions. ActiveReports includes a range of functions, including running value, population standard variance, standard deviation, count, minimum and maximum. For e.g., use the following expression to get a count of employees.
=Count(Fields!EmployeeID.Value, Nothing)