More flexible aggregation when extracting data