0
0
Google Sheetsspreadsheet~15 mins

Why QUERY is Google Sheets' most powerful function - Business Case Study

Choose your learning style9 modes available
Scenario Mode
👤 Your Role: You are a data analyst at a retail company.
📋 Request: Your manager wants a clear summary of sales data filtered by region and product category, showing total sales and average price.
📊 Data: You have a sales dataset with columns: Date, Region, Product Category, Product Name, Units Sold, Unit Price, and Total Sales.
🎯 Deliverable: Create a summary table using the QUERY function that shows Region, Product Category, total Units Sold, average Unit Price, and total Sales, filtered to only include regions with sales above 1000 units.
Progress0 / 5 steps
Sample Data
DateRegionProduct CategoryProduct NameUnits SoldUnit PriceTotal Sales
2024-01-05EastElectronicsHeadphones150507500
2024-01-07WestElectronicsSpeakers2008016000
2024-01-10EastFurnitureDesk10012012000
2024-01-12NorthElectronicsMonitor30015045000
2024-01-15SouthFurnitureChair80756000
2024-01-18WestFurnitureTable12020024000
2024-01-20NorthFurnitureShelf901009000
2024-01-22EastElectronicsCamera13030039000
2024-01-25SouthElectronicsSmartphone250400100000
2024-01-28WestElectronicsTablet18035063000
1
Step 1: Select the entire data range including headers (A1:G11).
No formula needed.
Expected Result
Data range selected for QUERY function.
2
Step 2: Enter the QUERY formula to summarize total Units Sold, average Unit Price, and total Sales by Region and Product Category.
=QUERY(A1:G11, "select B, C, sum(E), avg(F), sum(G) group by B, C", 1)
Expected Result
Table showing Region, Product Category, sum of Units Sold, average Unit Price, and sum of Total Sales.
3
Step 3: Modify the QUERY formula to include only regions where total Units Sold is greater than 1000.
=QUERY(A1:G11, "select B, C, sum(E), avg(F), sum(G) group by B, C having sum(E) > 1000", 1)
Expected Result
Filtered summary table excluding regions with total Units Sold 1000 or less.
4
Step 4: Format the summary table headers for clarity: Region, Product Category, Total Units Sold, Average Unit Price, Total Sales.
Manually rename headers in the output or use QUERY label clause.
Expected Result
Clear headers on the summary table for easy understanding.
5
Step 5: Use the QUERY label clause to rename columns in the formula for better readability.
=QUERY(A1:G11, "select B, C, sum(E), avg(F), sum(G) group by B, C having sum(E) > 1000 label sum(E) 'Total Units Sold', avg(F) 'Average Unit Price', sum(G) 'Total Sales'", 1)
Expected Result
Summary table with friendly column names.
Final Result
Region    | Product Category | Total Units Sold | Average Unit Price | Total Sales
----------|------------------|------------------|--------------------|------------
East      | Electronics      | 280              | 175                | 46500
West      | Electronics      | 580              | 170                | 79000
West      | Furniture        | 120              | 200                | 24000
North     | Electronics      | 300              | 150                | 45000
South     | Electronics      | 250              | 400                | 100000
East and West regions have strong sales in Electronics and Furniture.
South region has high sales in Electronics but lower in Furniture.
North region has balanced sales but lower total units compared to West.
Regions with total units sold above 1000 are included, filtering out smaller sales.
Bonus Challenge

Create a dynamic QUERY formula that updates the summary automatically when new data rows are added below the current data.

Show Hint
Use an open-ended range like A1:G or use named ranges to include new data automatically.