Use the QUERY Function for Consultant-Style Analysis

Use the QUERY Function for Consultant-Style Analysis

What You Will Learn

You will learn how to ask Gemini to write QUERY formulas that group, filter, sort, and summarize data in a SQL-like way.

Required Dataset

Use the workbook from Lesson 27.

You will use:

Dynamic_Array_Practice

Create one new tab:

Query_Analysis

Before You Start

Make sure Dynamic_Array_Practice includes these fields:

Region

Product Category

Customer Segment

Revenue

Gross Margin Dollars

Status

The QUERY function is useful when you want a compact summary table without building multiple SUMIFS formulas.

Step-by-Step Instructions

Step 1. Ask Gemini for a basic QUERY formula

Open Gemini and enter:

Act as a Google Sheets formula coach.

Create a QUERY formula using Dynamic_Array_Practice.

Business question: What is total Revenue and Gross Margin Dollars by Region?

Fields:

– Region is column A

– Revenue is column D

– Gross Margin Dollars is column E

Return the formula, explanation, and validation step.

Expected formula:

=QUERY(Dynamic_Array_Practice!A1:F,”select A, sum(D), sum(E) where A is not null group by A label A ‘Region’, sum(D) ‘Total Revenue’, sum(E) ‘Total Gross Margin Dollars'”,1)

Step 2. Add filtering

Ask Gemini:

Modify the QUERY formula to include only rows where Status equals Active.

Expected pattern:

=QUERY(Dynamic_Array_Practice!A1:F,”select A, sum(D), sum(E) where F = ‘Active’ group by A label A ‘Region’, sum(D) ‘Total Revenue’, sum(E) ‘Total Gross Margin Dollars'”,1)

Step 3. Add sorting

Ask Gemini:

Sort the QUERY output by total Revenue descending.

Expected pattern:

=QUERY(Dynamic_Array_Practice!A1:F,”select A, sum(D), sum(E) where A is not null group by A order by sum(D) desc label A ‘Region’, sum(D) ‘Total Revenue’, sum(E) ‘Total Gross Margin Dollars'”,1)

Expected Result

Your Query_Analysis tab should contain a summary table that groups revenue and margin by region, with optional filters and sorting.

Check Your Work

Manually filter the source data for one region and compare the total revenue to the QUERY output. Check that column letters are correct, text criteria are in quotes, and the header row number at the end of the formula is correct.

Optional Extension

Ask Gemini:

Create a QUERY formula that summarizes Revenue and Gross Margin Dollars by Region and Product Category, only for Active rows, sorted by Revenue descending.

How to get started

1

arrow-down-blue

Tell us about your project

2

arrow-down-blue

Interview candidates

(We’ll provide bios within 48 hours on average)

3

Select your consultant and start work

Find a Consultant

or email us at: [email protected]