Summary functions work on related fields just as they do on the regular fields in a table. You can summarize the contents of a portal's data using a calculation field to create an account statement for individual clients, for example.
To summarize related data
1 .Open your current table and go to the layout that holds your portal. Choose File > Define > Database (Control+Shift+D/Command+Shift+D). When the Define Database dialog box appears, click the Fields tab.2 .Type a name for the field, choose Calculation (Control+L/Command+L) in the Type drop-down list (Figure 6.37), then click Create.
Figure 6.37. Related fields can be summarized with a calculation field.
In this example, the field name is Sales Summary.3 .When the Specify Calculation dialog box appears, double-click an aggregate function from the function list on the right (Figure 6.38).
Figure 6.38. Aggregate functions statistically summarize all record data in a field according to the function type you select.
Depending on what type of information you want, you can use Sum, Average, Count, Max, Min, StDev, or StDevP. In our example, we've chosen Sum because we want to add all of the records.4 .Click the drop-down menu above the field list on the left and select the relationship for the field you want to summarize (Figure 6.39).
Figure 6.39. Before you choose a field, choose the table occurrence from the drop-down menu.
The field list will change to display the fields in the source table. Because they're related fields, their names begin with a double colon.5 .In the field list, double-click the field you want to summarize (Figure 6.40).
Figure 6.40. Choose the field you want to summarize from the field list on the left.
6 .The two related field names (the one in the current table and its related field in the source) will appear in the formula box.7 .Leave the calculation result set to Number. Click OK twice to finish.8 .Switch to Layout mode (Control+L/Command+L) and add the field to the layout outside the portal.In our example, we've added a Sales Summary field (Figure 6.41).
Figure 6.41. Put the summary calculation field in the layout body, not in the portal.
9 .Choose Format > Number.When the Number Format dialog box appears, you can specify the exact format in which you want the summary information to appear (Figure 6.42).
Figure 6.42. You can display the summary field in any standard number format.
In this case, we chose the "Format as decimal" radio button and set it to display the number to two decimal places. We also used a comma to set off the thousands place.10 .Switch to Browse mode to see the total for that record in the summary field (Figure 6.43).
Figure 6.43. The summary calculation field displays the total of the fields in the current record's portal.