Show Calculations Property
Another important property is Show Calculations. In the Key Browser, set the Show Calculations property to 'true' and expand Datasources. You'll see the 'count' key was added under Datasources. A 'count' is the total number of rows in your Datasource. Expand your columns and you'll see that a number of built-in keys were added. For each column you can calculate the following: value, total of all the values in that column, average, maximum value, minimum value, running total, and running average. These keys are available for each column that you bring into your table once you set Show Calculations to 'true'. The Show Calculations property can come in pretty handy once you're familiar with how it works.
Show Calculations is not recommended for text strings, but is great for showing numerical calculations.
By dragging any one of the calculation keys from the Key Browser on to a report, you will see the result of that calculation in the Preview Panel using the dataset below.
- In this example, we'll use the following dataset containing several cities along with their populations to show how the Show Calculations property and associated keys work.
- From the Report Components palette, drag a table into the Design Panel. Next, drag your datasources to columns in your table.
- In the Key Browser, set the Show Calculations property. You'll notice that the 'count' key was added under Datasources and the calculation keys were added to each column in your datasource. Expand any of your datasources to see see the calculation keys.
- In the Design Panel, drag any of the calculation keys to your table. You can see we randomly placed the 'max' and and 'average' keys on the report. The calculation keys were converted to keychain expressions (i.e., '@Countries.max.Population@,' and '@Countries.average.Population@') in the report. One thing to keep in mind if you are using the Show Calculations property, is you may need to do some formatting of your table rows and headers so your calculations are displayed nicely on your report. You'll notice that Header and Summary rows were added. The Summary row contains the '@total.Population@' so it will look nice in the report.
- Once you add your calculation keys to your table, go to the Preview Panel to see what your report looks like. It's not unusual to have to go back to the Design Panel to tweak the formatting. If you don't like the number format, you can go to the Property Inspector and change the format of the Number property. Number and Date formats are discussed later in this page.