Skip to content

Aggregating and Grouping Data

Aggregation transforms many rows into fewer, more meaningful summary rows. Instead of looking at 10,000 individual transactions, you see monthly totals. Instead of every customer record, you see counts by segment. This guide covers the aggregation techniques you’ll use in almost every analysis.

Aggregation answers “how much?” and “how many?” questions by combining multiple values into summaries.

Raw dataAggregated
10,000 order rowsTotal revenue: $1.2M
500 customers150 Premium, 350 Standard
Daily sales for a yearMonthly averages

Without aggregation, you’re drowning in details. With it, you see the big picture.

Let’s use a simple orders table to illustrate aggregation concepts throughout this guide:

OrderDateRegionCategoryCustomerAmountUnits
1Jan 15EastElectronicsAcme Corp$1,2002
2Jan 18WestClothingBeta Inc$3505
3Jan 22EastElectronicsAcme Corp$8001
4Feb 03WestElectronicsGamma LLC$2,1003
5Feb 10EastClothingDelta Co$4254
6Feb 14EastElectronicsAcme Corp$9502
7Feb 20WestClothingBeta Inc$2753
8Mar 05EastClothingDelta Co$6006
9Mar 12WestElectronicsGamma LLC$1,8002
10Mar 18EastElectronicsAcme Corp$1,5003

This small dataset has multiple dimensions you can slice by (Region, Category, Customer, Month) and multiple values you can calculate on (Amount, Units). We’ll use it to show the difference between pivots and grouped aggregations.

Add up values across rows:

"What's the total revenue?"
"Sum of units sold"
"Total expenses for 2024"

From our example: Total Amount = $10,000, Total Units = 31

Count rows or distinct values:

"How many orders are there?"
"Count of unique customers"
"How many products have been sold?"

From our example: 10 orders, 4 unique customers

Calculate the mean value:

"What's the average order value?"
"Average customer age"
"Mean time to resolution"

From our example: Average order = $1,000

"What's the median order value?"
"Min and max prices"
"Standard deviation of revenue"
FunctionWhat it tells you
SumTotal across all rows
CountNumber of rows
Count DistinctNumber of unique values
Average (Mean)Typical value (affected by outliers)
MedianMiddle value (robust to outliers)
Min / MaxRange of values
Standard DeviationHow spread out values are

Grouping vs Pivoting: Understanding the Difference

Section titled “Grouping vs Pivoting: Understanding the Difference”

If you’ve used Excel pivot tables, you’re familiar with viewing one metric across two dimensions—like Revenue by Region and Quarter in a grid. That’s powerful, but it’s just the beginning.

Grouping in Querri lets you calculate many metrics at once for each combination of dimensions. This is where the real analytical power lives.

A pivot table shows a single calculation spread across rows and columns:

"Pivot total revenue by Region and Month"
RegionJanuaryFebruaryMarch
East$2,000$1,375$2,100
West$350$2,375$1,800

This is great for spotting patterns—you can immediately see that West had a strong February while East was steadier across months.

Pivots are perfect for:

  • Quick visual comparisons across two dimensions
  • Heatmap-style analysis
  • Period-over-period views (months as columns, categories as rows)
  • Presentation-ready tables

Grouped Aggregations: One Dimension, Many Metrics

Section titled “Grouped Aggregations: One Dimension, Many Metrics”

Here’s where Querri shines. Instead of one metric across a grid, calculate everything you need for each group:

"Group by Region and calculate total revenue, order count, average order value, total units, and units per order"
RegionTotal RevenueOrdersAvg OrderTotal UnitsUnits/Order
East$5,4756$913183.0
West$4,5254$1,131133.3

Now you’re not just seeing revenue—you’re seeing the story. East has more orders but smaller average values. West has fewer, larger orders. This single table gives you five insights instead of one.

You can group by multiple dimensions AND calculate multiple metrics:

"Group by Region and Category, then calculate total revenue, order count, average order value, and total units"
RegionCategoryRevenueOrdersAvg OrderUnits
EastElectronics$4,4504$1,1138
EastClothing$1,0252$51310
WestElectronics$3,9002$1,9505
WestClothing$6252$3138

This tells you: Electronics drives revenue in both regions, but West’s electronics orders are much larger. Clothing has smaller order values but more units per order.

Use CaseBest ApproachWhy
”Show me revenue by region and month”PivotClean grid for comparison
”Analyze customer behavior”Grouped metricsNeed multiple KPIs per customer
”Compare Q1 vs Q2 by product”PivotTwo-way comparison
”Build a segment profile”Grouped metricsMany attributes per segment
”Quick visual pattern scan”PivotEasy to spot outliers in grid
”Export data for further analysis”Grouped metricsMore flexible downstream

When you’re exploring, ask for lots of metrics to see what’s interesting:

"Group by Customer and calculate everything useful: total revenue, order count,
average order, total units, first order date, last order date, days as customer,
number of categories purchased, favorite category"

You might discover that your best customers by revenue aren’t your most frequent buyers—or that certain customers only buy one category while others buy across your whole catalog.

For reports and dashboards, narrow down to the metrics that matter:

"Group by Region and Category showing total revenue, order count, and average order value.
Sort by revenue descending."

Then export or add to a dashboard:

"Export this to Excel"
"Add this table to my Sales Dashboard"

See trends over time:

"Monthly revenue for 2024"
"Weekly order counts"
"Daily active users"
"Quarterly sales by region"

Understand composition:

"Revenue by product line"
"Customers by segment"
"Orders by status"
"Sales by channel"

Find the leaders and laggards:

"Top 10 customers by revenue"
"Bottom 5 products by sales"
"Top 20 cities by order count"

Compare time periods:

"Compare this month's revenue to last month"
"Year-over-year growth by category"
"This quarter vs same quarter last year"
"Create a pivot table of sales by region and quarter"
"Pivot revenue by product category and month"
"Cross-tab orders by day of week and hour"

Example result:

RegionQ1Q2Q3Q4
East$120K$135K$128K$142K
West$98K$110K$105K$118K
Central$85K$92K$88K$95K

Pivot tables are great for:

  • Spotting patterns across two dimensions
  • Heatmap visualizations
  • Period-over-period comparisons

Go beyond raw numbers to meaningful metrics.

"What percentage of revenue is each product category?"
"Show customer count as percentage of total by segment"
"Revenue share by region"
"Calculate profit margin by product (profit / revenue)"
"Conversion rate by channel (purchases / visits)"
"Average revenue per customer by segment"
"Month-over-month revenue growth"
"Year-over-year customer growth by segment"
"Calculate growth rate from first to last month"

Charts work better with summarized data:

"Group by month and calculate total revenue, then create a line chart"

Charting 12 monthly totals is clearer than 10,000 daily transactions.

Reports need summaries, not raw data:

"Group by Region and Category with revenue, orders, and average order value. Export to Excel."

Build live dashboards from aggregated views:

"Add this regional summary to my Sales Dashboard"
"Create a dashboard widget showing monthly revenue trend"

The aggregation updates automatically when underlying data changes.

Group by dimensions that matter for your question:

  • Time: When did things happen?
  • Geography: Where did things happen?
  • Category: What type of things?
  • Customer segment: Who did things?

Aggregations with few rows can be misleading:

"Show me the count per group as well as the average"

An average of 2 data points isn’t reliable.

Nulls in your grouping column create an awkward “(null)” group:

"Fill null categories with 'Unknown' before grouping"

When creating new metrics:

"Calculate total revenue as 'total_revenue' and order count as 'num_orders'"

Clear names make results easier to understand and export cleanly.

”My totals don’t match the original data”

Section titled “”My totals don’t match the original data””

Check for:

  • Filtered rows — Did you filter before aggregating?
  • Null values — Nulls are excluded from sums by default
  • Duplicates — Duplicate rows inflate totals
"Compare sum of revenue before and after grouping"

High-cardinality columns (like customer_id) create too many groups:

"Group by segment instead of individual customer"
"Filter to top 10 products before grouping by product"

Possible causes:

  • Rounding errors (usually harmless)
  • Filters applied inconsistently
  • Null values excluded
"Show the raw numbers along with percentages"

”Period comparison shows weird results”

Section titled “”Period comparison shows weird results””

Check that both periods have complete data:

"How many days of data are in each period?"

Comparing a full month to a partial month gives misleading results.

  1. Start with grouped metrics for exploration — Cast a wide net, then narrow down
  2. Use pivots for presentation — Clean grids are easier to scan
  3. Always include counts — Know how many records are in each group
  4. Check for outliers — One huge value can skew an average
  5. Consider median vs mean — Median is more robust for skewed data
  6. Export clean, labeled data — Your future self will thank you

With aggregation skills, you’re ready for more advanced analysis: