Creative Wisdom ยท FileMaker Pro tipsArchive

Subtotal by pay period and account

Chong Ho (Alex) Yu, Ph.D., MCSE, CNE (2001)

Problem

I have a timecard database. In the payroll different employees are paid by different accounts. I would like to see the sumtotal of each account within a pay period on the Web. The search result should look like the following table:

datenameratehourstotalaccountsubtotal by
account
1.9.98Alex Yu$ 7.7540$ 310AB11011$ 940
1.9.98Bill Clinton$ 8.0040$ 320AB11011$ 940
1.9.98Al Gore$ 7.7540$ 310AB11011$ 940
1.9.98Bill Gates$ 6.0020$ 120CD22000$ 312
1.9.98Steve Job$ 9.6020$ 192CD22000$ 312

Solution

First, create a calculation field named "date_account", which concatenates the date and the account. In the formula you must cast the variable type of "date" from date to text by using the function "DateToText."

   	DateToText(date)&account

Next, create a summary variable named "sumtotal." Choose "total" as the summary option and the total pay as the summing variable (see below). This field just adds up all pay amount but does not give you a subtotal by group.

To get the subtotal of account by date, create another calculation field entitled "sum_by_date_account". Then extract the subtotal from "sumtotal" by using the function GetSummary with the subgroup "date_account."

 	GetSummary(sumtotal, date_account)

However, the subtotal will not take effect unless the data are sorted by "date_account." You can pre-determine the sort order in "search.html" by adding the following line into the webpage. Now the search result could present the result as what you expect.

 	
	<INPUT TYPE="hidden" NAME="-SortField" VALUE="date_account">