add optional filter and totals