Add Additional Fields Using Expressions

Even though the report has been created, you can edit the report to add fields from the DataBlock or add fields created from expressions.  To illustrate this, two fields will be added to the report.  The first field will have the last name and first name concatenated into one field (with a space between the names).   The other field will contain the date the report was run.  This will illustrate how to utilize the Expression Builder.

Highlight the report within the Navigation Pane, click Edit Report, then click the Design Button to bring up the “Edit CSV Report” dialog box again as shown in the following figure.

The Edit CSV Report dialog with ID, Last Name, First Name, Salary, Department ID, and Location ID fields selected to be included in the report.

To add the first field, click the expression builder button Expression Builder button. The button reads e equals m c squared., which brings up the Expression Builder dialog box shown below.

The Expression Builder dialog. This dialod contains various operators for creating an expression.  Operators include equals, less than, greater than, among others.  You can also include functions, variables, and database fields.

icon Function
Function buttonn on the expression builder dialog. Choose functions from library
Variable button Add system variables.
Database field button. Looks like two wireless symbols sitting back to back. Lists available database fields.
Plus button on the expression builder window. Concatenate fields. Leading/trailing spaces are removed.

Click the database field icon Database field button. Looks like two wireless symbols sitting back to back. to bring up the list of database fields, then double-click on {Employees.last_name} to place the field in the Expression Builder.

The Expression Builder dialog with Employees.last name filled in.

Click on the plus sign (to concatenate) and add a blank space (surrounded by single quotes) to leave room between the last and first name.

{Employees.last_name} + ' '

Click the database field icon Database field button. Looks like two wireless symbols sitting back to back. again to display the list of fields, then add the {Employees.first_name} field.
The expression will look like this:

{Employees.last_name} + ' ' + {Employees.first_name}

Click OK then enter the name for this new field.

Field Name dialog with Last First entered as the name of the expression.

The figure below shows the new field (lastfirst) added to the original list of fields.

Edit CSV Report dialog with the new expression field added.

To create the other field which will contain today’s date, a similar process is used.  Within the above dialog box click the expression builder button Expression Builder button. The button reads e equals m c squared. then click the Function buttonn on the expression builder dialog. button to display a list of available functions.

The Choose a Function dialog with the Now function selected.

Click Date&Time, then Now to obtain today’s date.  Click OK and name the field Today.
The Edit CSV Report dialog with the Today field added.

Run the report and you will now see the concatenated last/first name in column G and today’s date/time in column H.

This image shows the report imported into Microsoft Excel which now includes the new expression fields.