In This Topic

Using Expression Editor

In This Topic

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 are enclosed within curly braces '{}'. Even the expression for a field value for a TextBox is set as follows: {LastName}.

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.

All expressions begin with an equal to sign (=). Even the expression for a field value for a TextBox is set as follows:

`{LastName}`

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: {LastName} , {FirstName}

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(<Condition>, <TruePart>, <FalsePart>)}`

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(FirstName = "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(EmployeeID, Nothing)}`

Calculation Option |
Result |
---|---|

No Calculation | Displays the value that is entered in the field. |

% of Grand Total | Displays values as a percentage of the grand total of all the values or data points in the report. |

% of Column Total | Displays all the values in each column or series as a percentage of the total for the column or series. |

% of Row Total | Displays the value in each row or category as a percentage of the total for the row or category. |

% of | Displays values as a percentage of the value of the Base item in the Base field. |

% of Parent Row Total |
Calculates values as follows: (value for the item) / (value for the parent item on rows) |

% of Parent Column Total |
Calculates values as follows: (value for the item) / (value for the parent item on columns) |

% of Parent Total |
Calculates values as follows: (value for the item) / (value for the parent item of the selected |

Difference From |
Displays values as the difference from the value of the |

% Difference From | Displays values as the percentage difference from the value of the Base item in the Base field. |

Running Total in | Displays the value for successive items in the Base field as a running total. |

% Running Total in | Calculates the value as a percentage for successive items in the Base field that are displayed as a running total. |

Rank Smallest to Largest | Displays the rank of selected values in a specific field, listing the smallest item in the field as 1, and each larger value with a higher rank value. |

Rank Largest to Smallest | Displays the rank of selected values in a specific field, listing the largest item in the field as 1, and each smaller value with a higher rank value. |

Index |
Calculates values as follows: ((value in cell) x (Grand Total of Grand Totals)) / ((Grand Row Total) x (Grand Column Total)) |