added support for grouping values (average, max)