Total a number of amounts in between two dates

how to total a number of amounts .
below gives the total without respect to the quarter

'invoices': collection ['post'] {
	'post': text @default: auto-increment || "01"
	'transaction date': number 'datum' @default: from @date-time 'datum en tijd' now
	'amount': number 'euro'
	'Quarter': stategroup = switch .'transaction day' compare ( 0 )  (
       ...
     ) (
       'Q1' { }
       'Q2' { }
       'Q3' { }
       'Q4' { }
    )
}
'total': number 'euro' = sum .'invoices'* .'amount'

how can the invoices in a certain quarter be totalled?

Like this:

'total Q1': number 'euro' = sum .'invoices'* .'Quarter'?'Q1' ^ .'amount'