'datasets.py' improvements to calculating aggregates for preview grid