You define totals and counters with sum variables or the corresponding aggregate functions. You will find more information about this in chapters Using Functions, Overview of Functions and Sum Variables.