Now that you've created a basic dynamic report, you need to clean it up and provide polish so it looks professional. Some simple changes can help you get to that point.
To format the numbering in the table, select the salary cell and the salary footer in the table. (Select multiple objects by pressing Ctrl and clicking the objects.). Now, complete these steps:
- Open the Property Editor.
- In the Properties pane, click Format Number.
- Select Currency from the Format Number as drop-down list, then change the symbol to be the dollar sign ($).
- Select the Use 1000s separator check box.
- Click General in the Properties pane, and make the column right-justified instead of left. Right-justify the header and footer for that column, as well.
Another customization you might consider is to hide the chief executive officer's (CEO's) salary. To do so, complete these steps:
- Highlight the SALARY cell and switch to the Property Editor.
- Click Visibility in the Properties pane and select the Hide Element check box.
- Select the For specific outputs option.
- Select the HTML check box.
- Click the ... button to build the expression.
- Type the expression
row["LASTNAME"] == 'Conrad'to filter out the CEO's salary, then click OK.
- Select the PDF check box, and type the same expression there. If you don't select this check box, the CEO's salary would be hidden when the report was viewed as a Web page, but not when a PDF was generated. Your report should now appear similar to Figure 8.
Figure 8. Report with the CEO salary filtered
A better solution is to add the Title column from the database to the Employee Salaries data set:
- Right-click Employee Salaries in the Data Explorer and click Edit.
- Add the Title column to the
Note that the order of the fields in the
selectclause doesn't matter.
- Click OK, then go back to the Property Explorer visibility section and change the expression to
row["TITLE"] == 'CEO'. Now any employee with the title of CEO will have her salary hidden on this report.
The next step in customizing this report is to distinguish people from the sales department. You can do this in any of several ways. A couple of options are to add the department field to the Employee Salaries data set and change the sort criteria for the table to sort first by department. Alternatively, you could provide some type of color-coding to the report.
For this report, leave the sorting by last name intact. Instead, change the report to italicize all the salespeople's names. Go back into the Employee Salaries data set and add the Department column to the
select clause, just as you just did for the title. Now, change the row of the table to look different depending on which department the employee is in.
To edit the properties for a row, you must select the detail row. Hover your mouse over the table and click the Table tab that appears. Doing so brings up the outline for the table so you can click the entire row, as shown in Figure 9.
Figure 9. Selecting the entire row
With that row highlighted, complete these steps:
- Open the Property Editor and click the Highlights tab.
- Click Add and click the ... button at the top.
- Use the Expression Builder to create the expression
row["DEPARTMENT"]and click OK.
- Select Equal from the second list and type
"Sales"in the third box. Make sure that you include the quotation marks in the field. In this way, you can change the format of the row for all rows where the employee is in the Sales department.
- Change the font, size, and color of the text for that row. Set the font to Arial, blue, and italics.
- Click OK, and preview the report. It should look similar to Figure 10.
Figure 10. Report with the sales rows highlighted
What if my company has a large number of employees? You need to be able to allow management or human resources to pull up just one individual's information. You can use Report Parameters to limit the results shown to the user. With Report Parameters, you can prompt the user for information before the report is run. In this case, you'll prompt users to select a name:
- Right-click Report Parameters in the Data Explorer and click New Cascading Parameter.
- Change the name to
EmployeeNameand click Create New.
- Name the data set
EmployeeName,and type the query
SELECT lastname, firstname FROM employees.
- Click OK.
- Select the new data set from the Data Set list.
- Double-click the first row of the Value column in the grid below and select last name.
- Double-click the Display Text column and select the same.
- In the Properties area, name the parameter
Last nameand set the prompt text to
Enter last name of employee.
- In the second row, do the same with the name
First name, then click OK.
Now you need to tell the table to filter the results based on those parameters:
- Select the table, switch to the Property Editor, then click the Filters tab.
- Click Add in the upper-right corner of the tab.
- Double-click the Expression column of the new filter criteria and switch to the Expression Editor.
- Use the Category and Sub-Category to highlight your new Report Parameter group, then double-click Last name. When you click OK, the Expression column should read
- Click in the Value 1 column and select build expression and LASTNAME from the data set. Click OK. That cell should read
- Add another filter criterion and set it for first name.
- Right-click your report in the Navigator and click Run Report.
You'll be prompted to type a last name and first name for the employee you want to see. When you type a last name, BIRT restricts the list of first names from which you can select to only those where the last name matches your selection. You can also use the Preview window to see the results of this, but BIRT won't always prompt you to type the parameter values. In the upper-left corner of the Preview window, click Show Report Parameters to specify new values to preview with.