Tables with composite headers

Top  Previous  Next

Our previous example contained a single value per line and single column headers. Let's look at a cross-tab design having a composite header with more than one value. The source data has data in the following format:

 

Name        Year        Month                Days        Salary

Ann        1999        2                3        1000

Ben        2002        1                5        2000

….

 

We have added the “Month” and “Days” fields containing the month number and the number of working days respectively. Several different reports can be constructed from this data, for example : salaries of employees over each year, broken down in months.

 

What kind of a report will we get? It must resemble the report from the previous example but having the annual data subdivided by month. The cross-tab object must be set up in the same manner as before. This time we will also drag the “Month” field into the column header list, as shown here:

 

clip0213

 

On preview we see the following report:

 

_img193

 

Note that FastReport has automatically added a column of intermediate totals, displayed after each year. This can be turned off in the cross-tab editor by de-selecting the “Subtotal” flag of the “Year” column element:

 

clip0214

 

Also note that the last column element in the column header list never has a “Subtotal” flag (including the case of a single element). In our example we do not need intermediate totals for each month, so the “Subtotal” flag can be turned off.

 

There is another feature of intermediate totals, if they are used: it might be preferable to head the intermediate total as “Year + year total” instead of “Total”. In the cross-tab object on the report page double-click the intermediate total cell and in the text editor type:

 

Total for [Value]

 

On report construction the “[Value]” expression is replaced by the actual value of the column header in the cell above:

 

_img195