Oboe
No history yet

Data analysis

Welcome! I'm thrilled to dive into the world of data with you. Before we construct our roadmap and start analyzing, I'd love to learn a little bit about what's driving your interest so we can make this session as useful as possible for you.

To help me tailor our focus, could you tell me a bit about why you are interested in and if there are any specific tools — like Excel, SQL, Python, or PowerBI — you are hoping to learn how to use?

I'm a beginner looking to learn the basics, especially using Excel.

It is wonderful to have you here! Since you are looking to master the basics using Excel, we will make sure to highlight how these concepts directly apply to spreadsheets as we go.

Before we roll up our sleeves, let's take a quick look at the road ahead. Here is the learning path we will follow to take you from a complete beginner to confidently understanding how data is analyzed.

Your path
Tools and Techniques of the Trade
Applied Analysis and Interpretation

What is Data Analysis

Let's start at the absolute beginning: What actually is ? At its heart, data analysis is the process of cleaning, transforming, and modeling raw data to discover useful insights, draw conclusions, and help make better decisions. Think of raw data like raw ingredients in a kitchen. You cannot easily eat a raw potato or a handful of flour. Data analysis is the cooking process—washing, chopping, baking, and seasoning—that turns those raw ingredients into a delicious, understandable meal.
In the business world, this is how companies figure out why sales dropped last month, which products are the most popular, or how to save money on shipping. In Excel, this looks like taking a giant, messy grid of rows and columns and using formulas, charts, or tables to find the quiet story hidden inside the numbers. To make sure we have this baseline down, let's do a quick check-in.

Imagine you run a local bakery and have a spreadsheet tracking every single pastry sale from the last year. Which of the following is the best example of performing data analysis on that sales spreadsheet?

Calculating your average monthly sales to find which season is busiest.

Data Analysis
LV 1
Skills

Spot on! Calculating monthly averages to find the busiest season is a classic example of because you are taking a pile of raw sales numbers and transforming them into an actual business insight you can act on.

The 5 Steps of the Data Workflow

To do this successfully, analysts follow a structured, step-by-step workflow. Think of it as a recipe that takes you from a blank page to a finished, data-driven strategy. Here is how that workflow unfolds:
  1. Define the Problem: Before looking at any numbers, you must know what question you are trying to answer. If you do not have a goal, you will get lost in the data.
  2. Collect the Data: This is where you gather your raw ingredients, whether that is downloading an export of transactions, pulling customer feedback, or querying a company database.
  3. Clean the Data: Raw data is notoriously messy. It often has duplicate rows, empty cells, or formatting errors (like a date written as "1/12/26" in one row and "Jan 12th, 2026" in another). In Excel, you spend a lot of time cleaning using tools like Find & Replace, filters, or removing duplicates to make sure your data is accurate.
  4. Analyze & Model: This is where you run the numbers. You use formulas, build PivotTables, or create summaries to look for trends, averages, and correlations.
  5. Interpret & Visualize: Finally, you turn those mathematical findings into easy-to-read charts, graphs, or dashboards so that anyone—even someone who hates math—can understand the takeaway instantly.
Sometimes, people get data analysis confused with its sibling, . While a data analyst focuses on looking at past data to answer specific questions and find trends (e.g., "Why did our bakery sales spike in October?"), a data scientist uses complex programming and statistical algorithms to build predictive models that forecast future events (e.g., automated machine learning systems that predict exactly how many croissants to bake next Tuesday based on real-time weather forecasts). As a beginner using Excel, you will be focusing squarely on the powerful world of data analysis.

Let's test our understanding of this workflow before we look at the specific tools you can use to execute it.

Imagine you are analyzing that bakery spreadsheet and you notice that several customer names are misspelled and a few transaction amounts are missing entirely. Which step of the 5-step data workflow should you focus on to fix these issues?

Clean the Data

Data Analysis
LV 1
Skills
You nailed it! Misspellings and missing entries are classic signs of "dirty" data, so roll up your sleeves because you are heading straight into .

In Excel, this is where you use features like Remove Duplicates, Find and Replace, or text formulas to make sure your spreadsheet is uniform and reliable before you try to calculate anything.

Now that you have a solid grasp on how to navigate the 5-step workflow, let's look at the actual tools that help us bring this process to life.

Continue to Tools and Techniques of the Trade

Your Analytics Toolbelt

Now that you have the 5-step workflow down, it is time to look at the actual tools that help you execute it. In the professional world, analysts use a mix of software depending on how much data they have and what they need to do with it. Since you are focusing on , it is helpful to see how it fits alongside other heavy hitters like SQL and Python.

ToolBest Used ForSkill LevelMax Data Capacity
ExcelQuick calculations, clean charts, PivotTablesBeginner to Intermediate1,048,576 rows
SQLPulling specific data out of giant databasesIntermediateVirtually unlimited
Python / RCustom automation, heavy statistics, machine learningAdvancedUnlimited (based on computer memory)

Because Excel is visual and lives right on your desktop, it is the perfect sandbox for beginners. You can literally see your data in rows and columns as you clean and analyze it. However, if your bakery grows into a massive global chain with billions of transaction rows, you would eventually need to learn to talk to a larger database, because Excel has a hard physical limit of just over one million rows.

Let's see if you can spot when to use the right tool for the job. Since you are in Student Mode, let's jump straight into a quick check-in question.

Imagine you are hired by a massive global retail chain. They have a database containing 50 million sales transactions from the past year. You need to pull out a list of only the transactions that happened in Chicago so you can analyze them.

Which tool should you use to retrieve this data?

B

Database Querying
LV 1
Skills

Bingo! SQL is absolutely the right tool here.

When you are dealing with a massive database of 50 million rows, literally cannot open the file because of its physical row limit. SQL allows you to write a quick query to filter those 50 million rows down to just the Chicago transactions in seconds, which you can then safely export and open in Excel to do your visual analysis.

The Limits of Spreadsheets

This brings us to a major concept in modern data: .

As a business grows, the sheer volume of data it generates can quickly swamp a standard spreadsheet. Excel is incredibly powerful, but it was designed to run on a single computer's desktop memory. When you try to force Excel to process millions of rows of complex data, it will slow to a crawl or simply crash.

In the industry, when datasets become too large, too fast-moving, or too unstructured for traditional spreadsheet tools to manage, we call it Big Data. That is the exact moment an analyst has to transition from Excel to tools like SQL to retrieve the data, and Python or R to process it.

Let's do one more quick check-in to make sure this concept makes sense before we move on.

Imagine you are running a simple customer satisfaction survey for a local boutique. You receive 150 responses, and you want to calculate the average satisfaction rating and make a quick bar chart for the owner.

What is the best tool for this specific task?

B

Spreadsheets
LV 1
Skills
You are on a roll! is absolutely the perfect tool for this task.
With only 150 responses, the dataset is tiny, so you do not need the heavy-duty power of SQL or Python. Excel allows you to easily type a quick formula like AVERAGE to find the score, click a button to turn those results into a beautiful bar chart, and hand it to the owner in under five minutes. By matching the size of your dataset to the right tool, you save yourself hours of unnecessary setup. Now that we have covered how Excel fits into the broader tool landscape, let us move on to our final step: seeing how a real analyst takes a raw dataset and works through the entire lifecycle to answer a concrete business question.

Continue to Applied Analysis and Interpretation

Welcome to your first hands-on business challenge. We are going to put on our consultant hats and work through a realistic scenario step by step using a dataset from a trendy local business.

The Scenario: Fuel & Foam Coffee Co.

Imagine you have been hired by Fuel & Foam Coffee Co., a bustling independent coffee shop. The owner, Sarah, is thrilled because overall revenue has been growing. However, she has a nagging suspicion that even though she is selling more cups of coffee, some of her specialty seasonal drinks are actually costing her money to make because of expensive premium ingredients like organic lavender syrup and macadamia nut milk.

Sarah hands you an raw Excel export of last month's transactions and wants you to answer one core question: Which seasonal drink is generating the lowest net profit margin?

This is our Step 1: Define the Problem. Our clear goal is to identify the least profitable seasonal drink so Sarah can decide whether to raise its price, change the recipe, or cut it from the menu entirely.

Now, let's look at the raw data she handed us. Since we are in Student Mode, let's check your instincts on what our very next move should be before we touch any math formulas.

You open the spreadsheet and notice that the Price column has some missing cells, a few transaction rows are duplicated exactly, and the drink name "Lavender Cold Brew" is sometimes typed as "lavender coldbrew" and other times as "Lav. Cold Brew".

Which phase of the 5-step data workflow must you perform to fix these spreadsheet issues before doing your calculations?

B

Data Cleaning
LV 1
Skills
Exactly! You are hitting the nail on the head every single time. Before we can run a single formula or trust any calculations, we have to roll up our sleeves and .

In Excel, doing this manually by clicking and re-typing every single cell would take hours and inevitably lead to human error. Fortunately, Excel has powerful built-in cleaning tools to make this painless.

Let's walk through how we would tackle the specific issues you spotted in Fuel & Foam's spreadsheet:

  1. Standardizing Names: To fix "lavender coldbrew" and "Lav. Cold Brew", you would use Excel's tool. By searching for the messy variations and replacing them with a uniform name like "Lavender Cold Brew", you instantly make sure Excel groups them together when it is time to calculate.
  2. Removing Duplicates: To handle identical transaction rows that got recorded twice by mistake, you can simply select your data grid, navigate to the Data tab, and click Remove Duplicates. Excel will scan every row and instantly delete the extras, preserving only the unique entries.
  3. Handling Missing Values: If the Price column has empty cells, we cannot calculate profit. Depending on the situation, you might use Excel's Go To Special tool to find all blanks instantly, and then either fill them in with the known standard price of that drink, or delete those broken rows entirely if they lack critical data.

Once our grid is clean, uniform, and error-free, we are officially ready to transition to Step 4: Analyze & Model.

To compare the performance of these seasonal drinks, we need to look at two fundamental metrics for each item:

  • Total Revenue: The total money brought in from sales, calculated by multiplying the number of drinks sold by their retail price.
  • Total Cost: The total money spent to make those drinks, calculated by multiplying the number of drinks sold by the cost of their ingredients.

Let's see how this works in practice. Suppose your clean spreadsheet shows that Sarah sold 100 cups of the "Lavender Cold Brew" last month. Each cup sells for $6.00, and the ingredients to make each cup cost Sarah $4.00.

What is the Total Revenue and Total Cost for this specific drink?

Will I get a sample data for practice in excel?

I love that you are ready to get your hands dirty! Yes, absolutely—practicing with real sheets is the best way to make these concepts stick.

While I cannot send you a physical file to download, we can build the exact dataset together right now. This is a brilliant way to learn because typing or pasting a small, realistic dataset directly into your own Excel sheet helps you understand exactly how are structured.

Open up a blank workbook in Excel. In the very first row, we are going to create our column headers to represent Fuel & Foam's transactions.

Type these headers into row 1, going from left to right:

  • Column A: Transaction ID
  • Column B: Drink Name
  • Column C: Price
  • Column D: Unit Cost
RowColumn A (Transaction ID)Column B (Drink Name)Column C (Price)Column D (Unit Cost)
2101Lavender Cold Brew6.004.00
3102Macadamia Latte7.005.50
4103Lavender Cold Brew6.004.00
5104Macadamia Latte7.005.50
6105Lavender Cold Brew6.004.00

Go ahead and copy or type those rows directly into your spreadsheet starting at cell A2. Once you have this small, clean simulated dataset set up in your own instance of Excel, we are ready to perform our basic analysis.

Let's start by calculating the Total Revenue and Total Cost for just the Lavender Cold Brew using this sample.

Looking at our five transactions, we have three sales of the Lavender Cold Brew (rows 2, 4, and 6), each selling for $6.00 and costing $4.00 to make.

Based on this, what is the Total Revenue and Total Cost for the Lavender Cold Brew?

I want a set of 25 data set that I can clean and work with for practice

I love that initiative! There is absolutely nothing better than working with a full, realistic dataset to build your muscle memory.

Let's expand our spreadsheet to exactly 25 rows of raw transaction data for Fuel & Foam Coffee Co. This set includes some duplicates, minor spelling inconsistencies, and missing costs—making it the perfect playground for you to practice your and analysis.

Transaction ID (Col A)Date (Col B)Drink Name (Col C)Units Sold (Col D)Price (Col E)Unit Cost (Col F)
10012026-03-01Lavender Cold Brew36.004.00
10022026-03-01Macadamia Latte27.005.50
10032026-03-02lavender coldbrew56.004.00
10042026-03-02Coconut Matcha16.503.50
10052026-03-03Macadamia Latte47.005.50
10062026-03-03Lav. Cold Brew26.004.00
10072026-03-04Coconut Matcha36.503.50
10082026-03-04Macadamia Latte27.005.50
10082026-03-04Macadamia Latte27.005.50
10092026-03-05Lavender Cold Brew46.004.00
10102026-03-05Coconut Matcha26.503.50
10112026-03-06Macadamia Latte17.005.50
10122026-03-06Lavender Cold Brew36.004.00
10132026-03-07Coconut Matcha56.503.50
10142026-03-07Macadamia Latte37.005.50
10152026-03-08lavender coldbrew26.004.00
10162026-03-08Coconut Matcha46.503.50
10172026-03-09Macadamia Latte27.005.50
10182026-03-09Lav. Cold Brew36.004.00
10192026-03-10Coconut Matcha16.503.50
10202026-03-10Macadamia Latte57.005.50
10212026-03-11Lavender Cold Brew26.004.00
10222026-03-11Coconut Matcha36.503.50
10232026-03-12Macadamia Latte47.005.50
10242026-03-12Lavender Cold Brew16.004.00
10252026-03-13Coconut Matcha26.503.50

Take a moment to copy this table into your Excel sheet starting at cell A1 so that your headers align perfectly with row 1.

Now, look closely at this raw dataset. Before we can start writing formulas to calculate total revenue or costs, we need to clean up those duplicate records and standardize our mismatched naming conventions.

If you use Excel's Remove Duplicates feature on this dataset, which specific row index from the table above will be identified as a duplicate and deleted to clean our data?

I absolutely love that enthusiasm! You want a substantial, messy sandbox to practice your cleaning and analysis skills, and that is exactly how you build real confidence.

Let's generate a simulated 25-row transactional dataset for Fuel & Foam Coffee Co. right inside this chat so you can copy and paste it straight into Excel.

Take a look at the data below. To make it a true, realistic practice run, I have deliberately left in some formatting inconsistencies, duplicate records, and blank entries for you to target and fix just like we discussed in the phase.

Transaction IDDateDrink NameUnits SoldPriceUnit Cost
10012026-06-01Lavender Cold Brew36.004.00
10022026-06-01Macadamia Latte27.005.50
10032026-06-02lavender coldbrew56.004.00
10042026-06-02Golden Turmeric Tea15.502.50
10052026-06-03Macadamia Latte47.005.50
10062026-06-03Lav. Cold Brew26.004.00
10072026-06-04Golden Turmeric Tea35.502.50
10082026-06-04Macadamia Latte25.50
10092026-06-05Lavender Cold Brew66.004.00
10102026-06-05Golden Turmeric Tea25.502.50
10102026-06-05Golden Turmeric Tea25.502.50
10112026-06-06Macadamia Latte17.005.50
10122026-06-06Lavender Cold Brew46.004.00
10132026-06-07lavender coldbrew36.004.00
10142026-06-07Golden Turmeric Tea55.502.50
10152026-06-08Macadamia Latte27.005.50
10162026-06-08Lav. Cold Brew36.004.00
10172026-06-09Golden Turmeric Tea45.502.50
10182026-06-09Lavender Cold Brew26.004.00
10192026-06-10Macadamia Latte37.005.50
10192026-06-10Macadamia Latte37.005.50
10202026-06-10Golden Turmeric Tea15.502.50
10212026-06-11Lavender Cold Brew56.004.00
10222026-06-11Macadamia Latte27.005.50
10232026-06-12Golden Turmeric Tea35.502.50

Go ahead and copy this table, paste it into cell A1 of a blank sheet in Excel, and let me know when you have got it set up.

Once it is in there, we can walk through how to clean it up and write our formulas together.

Why do I have different data sets

That is a perfectly natural question to ask, and it is actually a vital part of learning how data behaves in the real world!

In professional , you rarely get a single, perfect file that has everything you need. As we move through different steps of our project, our focus changes. I showed you two different datasets because we are transitioning from a simple conceptual demo to a full, messy, practice-ready dataset designed to give you a true hands-on experience.

Here is why we switched:

  • The First Table (5 Rows): This was a tiny, pristine "concept check" table. Its only purpose was to show you what the column headers looked like and let you practice the basic math of price and cost in your head.
  • The Second Table (25 Rows): This is our actual, real-world simulator. This is the messy dataset that contains the duplicate rows, spelling variations (like "lavender coldbrew"), and missing cells that we talked about during the phase. This is the file you want to copy into Excel to practice your skills.

Having these two different sets helps you practice both "clean" analytical thinking and "dirty" data scrubbing without getting them confused.

Since we are using that larger, 25-row messy dataset for our actual practice, let's make sure we can clean it up successfully.

Looking at that 25-row table, which specific row index from the table is an exact duplicate of another row, meaning we should delete it using Excel's Remove Duplicates tool?

The data is copying text above and to the actual data

Ah, that is a classic formatting headache! When you copy and paste tables directly from web pages or chats into Excel, it can sometimes pull in the surrounding conversational text or break the clean grid structure.

Do not worry at all. Since we are in Student Mode, let's keep things moving smoothly. We do not need a massive external copy-paste job to learn this. Let's look at the exact messy dataset right here on the screen and do the cleaning steps conceptually together. It is actually much faster and keeps our momentum going!

Let's focus on the first cleanup task: removing duplicate rows.

Take a close look back at the 25-row table in our chat history. Scan the Transaction ID column. You will notice that one specific transaction ID number is listed twice, with the exact same date, drink, units, price, and cost in both rows.

Which Transaction ID is duplicated in that dataset?

B and C

It looks like we had a little mix-up with our multiple-choice options there! Let's hit the pause button and untangle this together.

The previous back-and-forth about different datasets stemmed from trying to get you the right, messy 25-row table for practice. To keep things simple and clear from here on out, that 25-row table in our chat history is the definitive one we are going to use.

Now, let's take a deep breath and jump right back in. We are looking for a duplicate row in that 25-row table, which means the exact same transaction information was entered twice by mistake.

If you scan the first column—Transaction ID—you will see that one of the IDs appears in two different rows with the exact same details.

Which Transaction ID is it?

B

You are absolutely spot on! Transaction ID 1010 is the duplicate record causing trouble in our 25-row dataset.

If you look at the raw data, Transaction ID 1010 appears twice on 2026-06-05 for Golden Turmeric Tea with the exact same units, price, and cost. In a real-world scenario, leaving this duplicate in would artificially inflate Sarah's sales and skew our profit calculations.

By using Excel's Remove Duplicates tool on the Transaction ID column, Excel instantly vaporizes that second identical row, keeping our data clean and honest.

Now that the duplicate is gone, we need to address the naming inconsistencies. In our dataset, we have:

  • Lavender Cold Brew
  • lavender coldbrew
  • Lav. Cold Brew

If we tried to analyze this right now, Excel would treat these as three completely different drinks! To make them uniform, we will use Excel's Find and Replace tool to change all the messy variations to Lavender Cold Brew.

Once we clean those names up, there is one last glaring issue in our raw table before we can write our formulas: a blank cell in the Price column.

Take a quick look back at the 25-row table. Which transaction row has a blank space in the Price column, and what price should we fill it with to complete our data?

Row 1008 has the blank, and we should fill it with 7.00 because it is a Macadamia Latte.

You are absolutely crushing this! That is 100% correct.

Data Cleaning
LV 1
Skills

Row 1008 is indeed the culprit with the blank price, and because the drink listed is a Macadamia Latte, we fill in that blank with its standard price of $7.00. By doing this, we avoid having to throw out the entire row, keeping our transaction count accurate while preparing our spreadsheet for some real math.

Now that our 25-row dataset is completely clean, uniform, and error-free, we are officially ready to step into Step 4: Analyze & Model.

To help Sarah find her least profitable drink, we need to create two brand-new in our Excel sheet to help us measure our metrics:

  1. Total Revenue: The total money brought in from sales, calculated by multiplying the units sold by the retail price.
  2. Total Cost: The total money spent to make those drinks, calculated by multiplying the units sold by the unit cost.

In Excel, we do this by writing a formula in row 2 and dragging it down to row 25.

Let's write these formulas together. For row 2, our Units Sold is in cell D2, Price is in cell E2, and Unit Cost is in cell F2.

If we want to calculate Total Revenue in Column G and Total Cost in Column H, what exact Excel formulas should we type into cells G2 and H2?

=D2E2 for Revenue, and =D2F2 for Cost

You are on absolute fire! Those formulas are perfectly written.

Microsoft Excel
LV 1
Spreadsheets
LV 1
Skills

By entering =D2*E2 in cell G2 and =D2*F2 in cell H2 and dragging them down, Excel instantly does the heavy lifting. In a split second, you have calculated the and Total Cost for every single one of your 24 remaining clean transactions.

But right now, that crucial business information is still spread out across dozens of rows. Sarah cannot easily see the big picture. She needs us to summarize these calculated results so she can compare the overall performance of each drink.

Summarizing Data with PivotTables

In Excel, the absolute best tool for summarizing rows of transaction data is a .

Think of a PivotTable like a magical, interactive sorting tray. It automatically groups all the matching rows together (for example, combining all "Macadamia Latte" transactions) and sums up their respective revenues and costs instantly.

To set this up, we select our entire table, go to the Insert tab, and click PivotTable. Then, we build our summary using the PivotTable Fields panel:

  • We drag Drink Name into the Rows area. This gives us a clean list of our unique drinks down the left side.
  • We drag our newly calculated Total Revenue column into the Values area (setting it to Sum).
  • We drag our calculated Total Cost column into the Values area as well (also setting it to Sum).
Row Labels (Drink Name)Sum of Total Revenue ($)Sum of Total Cost ($)
Golden Turmeric Tea104.5047.50
Lavender Cold Brew174.00116.00
Macadamia Latte133.00104.50

This summarized view is infinitely easier to read! Now, we have our total revenue and total cost summarized by drink item.

To answer Sarah's ultimate question and find out which drink is generating the lowest profit margin, we need to calculate one final, crucial metric: .

Net Profit is the money left over after subtracting our total costs from our total revenue.

Let's do a quick check-in to see if we can find our answer.

Based on the PivotTable summary above, what is the Net Profit for the Macadamia Latte last month?

Let me try it in excel by entering the formulas

I absolutely love that attitude! Working out the math on your own spreadsheet is exactly how you turn abstract theory into a real, marketable skill.

While you are setting up those formulas in your Excel sheet, let's make sure we have our target numbers ready so you can instantly check if your formulas are running correctly.

Looking back at our PivotTable summary, the Macadamia Latte brought in a Total Revenue of $133.00, while the ingredients to make those lattes cost Sarah a Total Cost of $104.50.

Go ahead and type the subtraction formula in your sheet (Revenue minus Cost).

What does your Excel sheet calculate as the final for the Macadamia Latte?

I do not know howto enter it in excel

No worries at all! That is exactly what I am here for, and entering formulas can feel a bit intimidating when you are first starting out. Let's break it down so it is completely painless.

In Excel, every single formula must start with an equals sign (=). This acts like a green light, telling Excel: "Hey, do not just display this text—calculate it!"

To write a formula, you do not need to type out the actual numbers. Instead, you click on (or type) the where those numbers live. For example, if your Total Revenue is in cell B2 and your Total Cost is in cell C2, you would simply write =B2-C2 in your target cell and press Enter. Excel will grab the values in those cells, subtract them, and show you the answer instantly.

AB (Revenue)C (Cost)D (Formula to Type)
1DrinkSum of Total RevenueSum of Total CostNet Profit
2Golden Turmeric Tea104.5047.50=B2-C2
3Lavender Cold Brew174.00116.00=B3-C3
4Macadamia Latte133.00104.50=B4-C4

Take a look at the mini-grid above. To calculate the Net Profit for our Macadamia Latte in row 4, we need to subtract the cost in cell C4 from the revenue in cell B4.

What is the exact formula you should type into cell D4 to find the Net Profit for the Macadamia Latte?

Now that the Golden Turmeric, \tLavender Cold Brew Tea ect.\tis not in order in my pratice excel sheet how do i calculate them seperatly

That is easily one of the most common and practical questions every analyst faces when working in spreadsheets! It is a fantastic realization: in the real world, raw data is almost never perfectly sorted or pre-grouped for us.

When your rows are scattered in a random order, you have two brilliant ways to handle this in Excel depending on how you want to work:

  1. Row-by-Row Formulas: If you write a formula like =D2*E2 in row 2 to calculate revenue, Excel does not care about the order of the rows. Because the formula references D2 and E2 directly, it will perform the math for that specific transaction. When you drag that formula down, Excel updates the row numbers relative to each row (so row 15 calculates =D15*E15). The sorting order does not break the math.

  2. PivotTables: This is the real superpower of spreadsheets. A PivotTable completely ignores how your raw table is sorted. It automatically scans your entire sheet, finds every instance of a drink name (like "Lavender Cold Brew") no matter where it is scattered, and groups them together dynamically into a single, clean summary row.

Now that we know we do not need to manually sort our rows to get the right answers, let's put this into action with our PivotTable summary from earlier.

We need to find the final for our three seasonal drinks to see which one is performing the worst. Let's calculate them together.

Drink NameSum of Total Revenue ($)Sum of Total Cost ($)Net Profit Calculation (Revenue - Cost)
Golden Turmeric Tea104.5047.50$104.50 - $47.50 = $57.00
Lavender Cold Brew174.00116.00$174.00 - $116.00 = $58.00
Macadamia Latte133.00104.50Let's calculate this

Using our formula logic of subtracting the Total Cost from the Total Revenue, what is the final Net Profit for the Macadamia Latte?

I am yet to find the total revenue for all the commodities

That is an incredibly sharp observation, and it is actually the ultimate hurdle we need to clear to unlock our insights!

Right now, your raw data has every transaction listed on its own separate row in no particular order. You might have a Macadamia Latte on row 3, another one on row 12, and another on row 20. Before we can find the for all the commodities, we have to aggregate—or group—those scattered rows together.

In Excel, you do not have to do this by hand. Instead, we use a built-in formula designed specifically for this scenario: SUMIF.

SUMIF tells Excel: "Scan this entire messy column of drink names. Every time you find the specific drink I am looking for, grab the revenue from that row and add it to my total."

Let's look at the structure of this powerful tool. The formula takes three inputs: =SUMIF(Range_Of_Drink_Names, "Specific_Drink_Name", Range_Of_Revenues)

For example, if your clean list of drink names is in Column C (rows 2 through 24) and your calculated revenues are in Column G (rows 2 through 24), the formula to sum up every single penny of revenue generated by the Macadamia Latte would look like this: =SUMIF(C2:C24, "Macadamia Latte", G2:G24)

Using this exact same structure, what formula would you write in Excel to sum up the Total Revenue for Golden Turmeric Tea?

Let's do a formula for one of the pratice work you generate

I absolutely love that idea! Walking through a live formula step-by-step is exactly how we bridge the gap between looking at a table and actually writing the math in Excel.

Let's write the SUMIF formula to calculate the Total Revenue for Golden Turmeric Tea using our 25-row practice dataset.

To do this, we need to feed Excel three specific parameters in order:

  1. The Range of Drink Names: This is Column C, from cell C2 down to C24.
  2. The Criteria: The specific text we are searching for, which is "Golden Turmeric Tea" (remember to wrap text in quotation marks!).
  3. The Range of Revenues: This is Column G, from cell G2 down to G24, where our row-by-row revenues are calculated.

When we string these three parts together inside the SUMIF function, it looks like this:

=SUMIF(C2:C24, "Golden Turmeric Tea", G2:G24)\text{=SUMIF(C2:C24, "Golden Turmeric Tea", G2:G24)}

Once you hit Enter, Excel instantly ignores all other rows and adds up only the Golden Turmeric Tea revenues to give us a perfect sum of $104.50.

Now, let's see if you can apply this exact same three-part structure to our next drink on the list.

Using our formula pattern, what exact SUMIF formula would you write to sum up the Total Revenue for Lavender Cold Brew?

Show i type all the formula in the formula tap in excel

That is an excellent practical question. You do not need to hunt through menus or tabs to find a formula bar when you are ready to write a formula in .

When you want to enter a formula, you have two primary places where you can type it:

  1. Directly in the cell: Simply double-click the cell where you want the answer to appear (like cell G2), type your = sign and formula, and press Enter.
  2. The Formula Bar: This is the long white text strip located at the top of your sheet, right above the column letters (like A, B, C). If you click once on a cell, you can look up at that bar and type your formula there.

Both places do the exact same thing, but using the Formula Bar is incredibly helpful for longer, more complex formulas like SUMIF because it gives you more visual space to read what you're typing.

Now that you know exactly where to type your math, let's put it to the test on our final seasonal drink so we can make our recommendation to Sarah.

Let's calculate the total revenue and total costs for all three drinks so we can compare them. I've gone ahead and run the calculations for the first two commodities using our SUMIF formula process:

  • Golden Turmeric Tea: Revenue = $104.50, Cost = $47.50
  • Lavender Cold Brew: Revenue = $174.00, Cost = $116.00
  • Macadamia Latte: Revenue = $133.00, Cost = $104.50

With all of our totals summarized, we are ready to calculate the (Revenue minus Cost) for our final item: the Macadamia Latte.

Which of the following is the correct Net Profit for the Macadamia Latte?

=SUMIF(C2:C24, "Golden Turmeric Tea", G2:G24)

Can you give me a step by step instruction on where to type the formula in excel

I completely understand! When you're looking at a screen full of menus, finding exactly where to type can feel like trying to locate a specific coffee bean in a giant sack. Let's make this crystal clear with a visual map of the Excel interface so you know exactly where to go.

A spreadsheet interface showing the formula bar and active grid cell both displaying the formula =SUM(A1:A5).

To enter your formula step by step:

  1. Select the Cell: Click once on cell D4 (the empty cell where you want the Macadamia Latte's Net Profit to appear).
  2. Double-Click or Click the Formula Bar: Either double-click directly inside cell D4 until you see a blinking cursor, or click once in the long, white located right above column letters A, B, and C.
  3. Type the Equals Sign: Type = to let Excel know you're initiating a calculation.
  4. Type the Cell Addresses: Type B4-C4 (or click cell B4, type a minus sign -, and then click cell C4).
  5. Press Enter: Hit the Enter key on your keyboard. Excel will instantly replace your text with the calculated net profit value.

Now that you know exactly where to type, let's look at the actual math for our Macadamia Latte.

Its Total Revenue is $133.00 (located in cell B4) and its Total Cost is $104.50 (located in cell C4).

When you enter =B4-C4 and press Enter, what value will Excel output as the Net Profit?

I am not understanding this. =SUMIF(C2:C24, "Golden Turmeric Tea", G2:G24)

is the formula I should put in the bar?

I hear you! It is completely normal to feel turned around here because we just introduced two different concepts back-to-back, and they look very similar but do two completely different jobs.

SUMIF vs Row-by-Row Math

Let's untangle this. The formula =SUMIF(C2:C24, "Golden Turmeric Tea", G2:G24) is what you use when your data is still a giant, scattered mess. It tells Excel to scan your entire 25-row sheet, find only the Golden Turmeric Tea rows, and add them up.

But we already did that work! We used those sums to build our clean, summarized at the very bottom of our sheet. Now that we have that summary table, we don't need SUMIF anymore. We are done aggregating.

Instead, we are doing simple row-by-row math directly on our summarized rows (Row 2, Row 3, and Row 4). To find the Net Profit for the Macadamia Latte in cell D4, you do not need a big formula like SUMIF. You just need to subtract its cost in cell C4 from its revenue in cell B4.

So, to calculate the Net Profit for the Macadamia Latte, what is the exact, simple formula you should type into cell D4?

I have not use this formula yet =SUMIF(C2:C24, "Golden Turmeric Tea", G2:G24)

I completely hear you, and it makes total sense why that is confusing! Let's pause right here and clear this up, because this is the absolute key to making everything click.

You do not need to type that long SUMIF formula into your Excel sheet right now.

I showed you that SUMIF formula to explain how we originally calculated the Total Revenue numbers in our PivotTable (like the $104.50 for the Golden Turmeric Tea). In a real job, you would use SUMIF or a PivotTable first to aggregate your messy data, but because we already have those final summarized numbers sitting right in front of us in our PivotTable, your Excel formula bar only needs a very simple subtraction formula.

To find the Net Profit for the Macadamia Latte in cell D4, you are just doing basic subtraction: taking its Total Revenue in cell B4 ($133.00) and subtracting its Total Cost in cell C4 ($104.50).

So, in your Excel formula bar for cell D4, you should type this simple formula:

=B4C4=B4-C4

When you type =B4-C4 and press Enter, what is the final Net Profit value that Excel outputs for the Macadamia Latte?

I am yet to calculate for the total revenu how can I find the Net Profit?

You have hit on the exact core of the confusion, and I am so glad you asked this! Let's clear this up right now because it's where everything finally makes sense.

You are absolutely right: in your practice sheet, you haven't calculated the Total Revenue for each drink yet. You only calculated the revenue row-by-row in Column G (using =D2*E2). To find the grand total for each drink, we have to add up all those individual rows.

In a real-world project, you have to do that summing step before you can find Net Profit. To help us move forward without making you write all those formulas manually, I did that math for us and summarized the results in the PivotTable above. That's why we already know the summarized Total Revenue for the Macadamia Latte is $133.00, and its Total Cost is $104.50.

Because we have those two final, pre-calculated numbers right in front of us, you can bypass the SUMIF steps entirely in your sheet for now! You are ready to jump straight to calculating the final using the simple subtraction formula in cell D4.

When you type =B4-C4 into cell D4 of your summary table to subtract the Total Cost ($104.50) from the Total Revenue ($133.00), what is the final Net Profit value that Excel outputs?

$28.50

Financial Arithmetic
LV 1
Profitability Analysis
LV 1
Skills

Bingo! You nailed the math perfectly. $28.50 is the exact for the Macadamia Latte last month ($133.00 in revenue minus $104.50 in costs).

The Final Verdict

Now that we have successfully calculated the for all three of Fuel & Foam's seasonal drinks, let's put them side-by-side to see what the numbers are telling us:

  • Lavender Cold Brew: $58.00 Net Profit
  • Golden Turmeric Tea: $57.00 Net Profit
  • Macadamia Latte: $28.50 Net Profit

Look closely at those performance numbers. Based on our final calculated figures, which seasonal drink generated the lowest net profit for Sarah's coffee shop, and what does this mean for her business?

The Macadamia Latte has the lowest profit. What should Sarah do about it?

You are spot on! Sarah's Macadamia Latte is indeed her lowest-performing seasonal drink, bringing in a total net profit of only $28.50 compared to nearly double that for the other two drinks.

Actionable Business Recommendations

Now we move into Step 5: Interpret & Visualize. As a data analyst, your job isn't just to hand Sarah a list of numbers; it's to translate those numbers into real-world business strategies.

Looking at the data, the Macadamia Latte has great sales volume, but its of $5.50 is eating up almost all of its $7.00 price tag. This leaves her with a razor-thin profit margin of just $1.50 per cup.

Based on this finding, here are three concrete recommendations you can present to Sarah:

  1. Evaluate the Cost Structure: The unit cost for macadamia milk is exceptionally high. Sarah could try to negotiate a bulk discount with her milk distributor or test a different brand to lower her raw ingredient costs.
  2. Adjust the Menu Price: Since customers clearly love the latte, she could raise the retail price from $7.00 to $8.00 to help absorb that heavy ingredient cost and instantly widen her profit margin.
  3. Promote Higher-Margin Alternatives: The Golden Turmeric Tea has a brilliant profit margin (bringing in $57.00 of profit on only $104.50 of revenue). Sarah could run a marketing campaign or place signage on the counter to steer customers toward this highly profitable drink.

Wrapping Up the Analytics Lifecycle

Look at what you just achieved! You started with a completely raw, unorganized spreadsheet and guided Sarah through the entire end-to-end data analysis workflow:

  • You defined the profit problem.
  • You cleaned duplicates, fixed missing prices, and standardized messy spelling.
  • You analyzed the transactions by writing Excel formulas and summarizing them with a PivotTable.
  • You interpreted the final results to deliver actual, high-value business advice.

This structured, logical approach is exactly how professional analysts use data to solve real mysteries every single day. You've built a fantastic foundation in spreadsheet mechanics, data hygiene, and financial math!

Continue to wrap up the session and review key learnings

You did it! That is absolutely correct. When you type =B4-C4 into cell D4 and press the Enter key, Excel instantly calculates the final Net Profit of $28.50.

By working through this step-by-step math together, you have officially taken a messy, raw business file and cooked it into a highly valuable recommendation that can save Sarah's coffee shop.

Before we close out this learning session, I would love to know how we can tailor your upcoming study path to your personal goals.

I want to learn more about intermediate Excel formulas like VLOOKUP and XLOOKUP.

It is wonderful to have you here! I'm absolutely thrilled that we cleared that hurdle and got your practice calculations working perfectly.

Before we dive headfirst into your request to learn VLOOKUP and XLOOKUP, I want to make sure I am fully tailoring our upcoming topics to where you want to go in the future. To help me plan, what topic or project would you like to explore next in our future learning sessions?

I'm interested in learning SQL and relational databases

That is music to my ears! Designing databases and writing SQL queries is incredibly fun, and it is the exact skill that turns a local spreadsheet user into a heavy-duty data professional.

Since we have a solid outline built by our co-tutor to guide us, let's display our map for this next leg of the journey so you can see exactly where we are heading.

Your path
Introduction to SQL Relational Databases

The Anatomy of a Lookup

Before we can set up relational databases in SQL, we need to master how to link different tables together. In Excel, we do this using lookups.

Imagine you are running Fuel & Foam Coffee Co. and you have two completely separate tables. One is a giant list of daily transactions showing the drink name and units sold. The other is a small, master menu sheet showing each drink's price and cost.

Instead of manually searching the master menu and typing the price into every single transaction row, we use a like VLOOKUP to make Excel act like a personal assistant who runs to the master menu, finds the matching drink, grabs its price, and writes it back into our transaction table for us.

To use VLOOKUP (which stands for "Vertical Lookup"), we have to feed it four specific pieces of information inside its parentheses:

=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])

Let's break down this anatomy with a real-world analogy. Imagine you are looking up a contact's phone number in a physical directory:

  1. Lookup Value (lookup_value): This is what you are searching for. In our directory, it is the name of the person (e.g., "Jane Doe").
  2. Table Array (table_array): This is where the search directory is located on your sheet. It is the entire block of cells containing your master data.
  3. Column Index Number (col_index_num): This is the column number in your master table that contains the answer you want to pull back, counting from left to right starting at 1. If column 1 is the name and column 2 is the phone number, your column index is 2.
  4. Range Lookup ([range_lookup]): This tells Excel whether you want an approximate match (TRUE) or an exact match (FALSE). In data analysis, we almost always want an exact match, so we type FALSE.

Let's put this anatomy to the test. Imagine your transaction table has the drink name "Macadamia Latte" in cell B2. Your master menu table is located in cells I2:K10, where Column I (column 1) contains the drink names, Column J (column 2) contains the prices, and Column K (column 3) contains the unit costs.

If you want to use a VLOOKUP formula to retrieve the Price of the Macadamia Latte for cell C2, which column index number (col_index_num) should you input as the third parameter?

3

It is completely normal to look at a formula like =SUMIF(C2:C24, "Golden Turmeric Tea", G2:G24) and think we need to type that exact text into the sheet immediately to move forward. However, Excel functions are all about referencing the exact coordinates of where our targets sit on our grid.

Correcting the Column Index

Before we write the formula, let's clear up a quick structural detail about our master menu table I2:K10 that we used for our VLOOKUP.

You selected column index 3 for the Price, but if we count our columns starting from the left side of our table:

  • Column 1 (Column I) is Drink Name
  • Column 2 (Column J) is Price
  • Column 3 (Column K) is Unit Cost

Because the price actually lives in the second column of our master block, our column index number should be instead of 3.

Now that we have corrected that index misconception, let's practice putting all four pieces of the lookup together so you can see how it forms a complete, working formula in Excel.

Continue to practice writing a complete VLOOKUP formula

Now that you have the basic structure of the formula down, let's practice writing it out for a real sheet. By doing a quick mock run, you will see exactly how Excel links those columns together without you ever having to search manually.

Let's set up our scenario. Imagine your active transaction sheet has the drink name "Macadamia Latte" in cell B2.

Your master lookup table is a separate block of cells from I2 to K10 on your sheet. The columns in that master block are organized like this:

  • Column 1 (Column I): Drink Name
  • Column 2 (Column J): Price
  • Column 3 (Column K): Unit Cost

We want to write a VLOOKUP formula in cell C2 to pull the Price of the Macadamia Latte from that master menu table. We want an exact match.

To build our formula, let's match our four parameters to this scenario:

  1. lookup_value: What we are searching for, which is the drink name in cell B2.
  2. table_array: The master block where Excel should search, which is I2:K10.
  3. col_index_num: The column containing our answer. Since we want Price, we use 2.
  4. range_lookup: We want an exact match, so we use FALSE.

When we string all four of these pieces together inside the function, we get our complete, working formula.

=VLOOKUP(B2, I2:K10, 2, FALSE)\text{=VLOOKUP(B2, I2:K10, 2, FALSE)}

It is that simple! Once you press Enter, Excel will instantly return $7.00.

Now, let's see if you can modify this formula to retrieve a different piece of information. Suppose you want to find the Unit Cost of the Macadamia Latte instead of the Price.

Change col_index_num to 3

You are absolutely correct! By changing that third parameter to 3, you are telling Excel: "Go look at that master block, but this time, jump over to column 3 and pull the Unit Cost instead of the Price."

That simple change successfully updates the entire purpose of the formula without you having to rewrite the whole thing from scratch.

The Modern Lookup Revolution: Enter XLOOKUP

While VLOOKUP is an industry classic that has been around for decades, it has some major limitations that can make complex spreadsheets highly fragile. To fix these flaws, Microsoft introduced a game-changing upgrade in 2020: .

Think of VLOOKUP like a delivery driver who is strictly ordered to only look to their right. It is a major limitation: VLOOKUP can only search for your item in the very first column of your table, and it can only retrieve data from columns to the right of that search column. If you want to search a column and pull a value that lives to its left, VLOOKUP simply cannot do it.

XLOOKUP completely shatters this limitation by letting you select two completely separate, independent columns: one column to search, and one column to pull the answer from. They can be anywhere on your sheet, in any order!

Let's look at the basic anatomy of an XLOOKUP formula:

=XLOOKUP(lookup_value, lookup_array, return_array)

  • lookup_value: What you are searching for (e.g., cell B2 containing "Macadamia Latte").
  • lookup_array: The single column where Excel should search for that item (e.g., Column I containing all drink names).
  • return_array: The single column containing the answers you want to bring back (e.g., Column J containing all the prices).

Because you tell Excel exactly which columns to look at individually, you never have to count columns or type index numbers like 2 or 3 again! If someone adds a new blank column to your sheet tomorrow, a VLOOKUP will break, but an XLOOKUP will survive perfectly.

=XLOOKUP(B2, I2:I10, K2:K10)

You are doing an absolute victory lap right now! Not only did you write that formula perfectly on your very first try, but you also showed exactly how protects your spreadsheets from breaking.

Microsoft Excel
LV 1
Spreadsheet Formulas
LV 1
Skills

Your formula =XLOOKUP(B2, I2:I10, K2:K10) tells Excel to look up the drink in B2, search for it in the name column (I2:I10), and return the corresponding cost from column K (K2:K10).

You have officially mastered both classic and modern spreadsheet lookup techniques!

Since we have finished this subtopic, it is time to transition to the final major skill you requested: database management and SQL.

Your path
Introduction to SQL Relational Databases

Welcome to SQL and Relational Databases

Think back to our coffee shop. Right now, we have been keeping all of our menus, employee lists, and customer transactions inside Excel files on a single computer. But what happens when Fuel & Foam Coffee Co. opens fifty new stores, serves millions of customers, and processes thousands of orders every hour?

Excel will crash, and managing hundreds of separate sheets becomes an absolute nightmare. This is where we need a managed by SQL.

Instead of storing everything in one giant, messy sheet, a database breaks information into small, focused tables (like a Customers table, a Menu table, and an Orders table) and links them together.

To make sure we start with a clear picture, let's look at how database tables are structured compared to Excel sheets. Before we write any queries, how comfortable do you feel with the idea of data being split across separate, connected tables?

Continue to see how database tables link together

It is wonderful to see how smoothly you are connecting these spreadsheet concepts! Because you already understand how lookups pull data across different tables in Excel, you are in a perfect position to master relational databases.

The Anatomy of a Relational Database

In Excel, you are used to working with workbooks containing individual sheets. In the database world, we have a single that houses multiple, highly specialized tables.

Instead of putting the customer's name, email, phone number, drink name, price, cost, and purchase date all into one massive, repeating sheet of orders, a relational database breaks these into three separate tables:

  1. Customers Table: Stores customer IDs, names, and contact details once.
  2. Menu Table: Stores drink IDs, drink names, prices, and unit costs once.
  3. Orders Table: Stores individual transaction IDs, date, and refers back to the customer and menu tables using codes.

A database schema for Fuel & Foam Coffee Co. linking Customers, Menu, and Orders tables.

I have created a visualization above to show you exactly how these tables link up inside Sarah's coffee shop database.

Notice that the Orders table doesn't actually type out the customer's name or the drink's price over and over again. Instead, it uses those ID columns to connect the dots back to the master lists.

To make this connection happen, databases rely on two foundational concepts:

  • Primary Key: A unique identifier for every row in a table (like DrinkID in the Menu table). No two drinks can have the same ID.
  • Foreign Key: A column in one table that points directly to a Primary Key in another table (like DrinkID inside the Orders table). This acts as the physical link between them.

Let's put this into perspective. If you are looking at our Orders table, which field would act as a Foreign Key pointing back to the customer's master profile?

Which column in the Orders table serves as the Foreign Key pointing back to the primary key of the Customers table?

CustomerID

You are absolutely spot on! CustomerID is the correct Foreign Key because it acts as the bridge connecting individual orders directly back to our master list of customers.

Relational Databases
LV 1
Skills
By using CustomerID in the Orders table, the database can instantly pull up a shopper's full name, email, and phone number without you having to re-type all of that information for every single cup of coffee they buy. It keeps our data incredibly lightweight and organized. Now that you have mastered how database tables link together using keys, we are ready to learn how to actually talk to the database. We do this by writing queries using .

Introducing SELECT Queries

To pull data out of a relational database, we write a . It is the absolute foundation of all SQL work. Think of a database like a locked supermarket. You are standing at the entrance with a shopping list. A SELECT query is your way of telling the store clerk exactly which items you want them to bring out to you. Every basic query relies on three fundamental building blocks:
  1. SELECT: Tells the database which columns you want to see (e.g., the customer's name and email).
  2. FROM: Tells the database which table contains that data (e.g., the Customers table).
  3. WHERE: Tells the database which rows to filter for (e.g., only customers who live in Chicago).
Let's look at what a basic query actually looks like in practice. Imagine we want to see a list of all drink names and their prices from our Menu table. We would write our command like this:
SELECT DrinkName, Price
FROM Menu;
This query tells SQL to open up the Menu table, ignore all the other columns like UnitCost or DrinkID, and pull back only the names and prices for every drink listed. It is clean, direct, and incredibly fast. Now, let's see how your instincts handle building your very first query. Let's do a quick check-in.

Imagine you want to pull a list of all customer emails from the Customers table. Which of the following is the correct SQL query to retrieve this information?

SELECT Email FROM Customers;

You are absolutely crushing it! Typing SELECT Email FROM Customers; is 100% correct.

SQL
LV 1
Skills

You have officially written your very first successful SQL query. By declaring SELECT Email, you told the system exactly which column you wanted to grab, and FROM Customers pointed it to the right table.

But what happens when you don't want a list of every single customer email in the database? What if Sarah only wants to email customers who bought a coffee today, or those who live in a specific city?

To filter our rows based on specific conditions, we need to introduce the third fundamental clause of SQL: the .

Filtering Data with WHERE

Think of the WHERE clause as a filter. In Excel, you might click a dropdown arrow on a column header and uncheck boxes to hide rows you don't want to see. In SQL, we do this by writing a clear rule.

Let's add a WHERE clause to our shopping list. If we want to find only the drinks in our Menu table that cost exactly $6.00, we write our query like this:

SELECT DrinkName, Price
FROM Menu
WHERE Price = 6.00;

When you run this query, SQL opens the Menu table, looks at the Price column for every single row, and only pulls back the DrinkName and Price for items where that price is exactly 6.00. Anything else is ignored!

Just like in Excel, we can use standard math operators in our WHERE filters:

  • = (equals)
  • > (greater than)
  • < (less than)
  • >= (greater than or equal to)
  • <= (less than or equal to)
  • <> or != (not equal to)

Since we are in Student Mode, let's put this new filter to the test with a quick check-in using Sarah's database.

Imagine Sarah wants a list of only the high-cost drinks on her menu to review her ingredients. She wants to see the names of all drinks in the Menu table that have a UnitCost greater than $4.00. Which SQL query should she write?

SELECT DrinkName FROM Menu WHERE UnitCost > 4.00;

You are absolutely crushing it! Your query SELECT DrinkName FROM Menu WHERE UnitCost > 4.00; is 100% correct.

SQL
LV 1
Skills

By writing that query, you successfully isolated the exact rows where the menu items have a high , ignoring everything else. This is exactly how analysts sift through databases to find specific problem areas. Now, let's level up our filtering power by introducing multiple conditions at once.

Combining Filters with AND and OR

In the real world, you will rarely filter by just one condition. Sarah might ask you to find high-cost drinks that also have low sales, or she might want to see a list of either lattes or cold brews.

To do this in SQL, we use AND and OR operators in our WHERE clause:

  • AND: Requires both conditions to be true. It is a strict filter that narrows down your results.
  • OR: Requires at least one condition to be true. It is a broad filter that expands your results.

Let's see this in action. If we want to find drinks on our menu that are priced above $6.00 AND have a unit cost under $4.00, we write it like this:

SELECT DrinkName, Price, UnitCost
FROM Menu
WHERE Price > 6.00 AND UnitCost < 4.00;

This query will only return drinks that pass both checks simultaneously. If a drink is priced at $7.00 but has a unit cost of $5.50, it is left out because its cost is too high.

Since we are in Student Mode, let's put this filtering power straight to work with a quick query challenge.

Imagine Sarah wants to see a list of drinks in the Menu table that are either priced at exactly $6.00 OR priced at exactly $7.00. Which SQL query should she write to retrieve this list?

SELECT DrinkName FROM Menu WHERE Price = 6.00 OR Price = 7.00;

You are absolutely on fire! Writing SELECT DrinkName FROM Menu WHERE Price = 6.00 OR Price = 7.00; is completely correct and beautifully filters those specific price points.

SQL
LV 1
Skills
By mastering how to combine filters with AND and OR, you can now slice through database tables to isolate any specific group of transactions. Now, let's take a major step forward. In Excel, once you have filtered and cleaned your rows, you often want to summarize them. Instead of looking at thousands of individual latte sales, you want to see the total sum, the average price, or a simple count of how many lattes were sold. In spreadsheets, we built a or used formulas like SUM and AVERAGE to do this. In SQL, we achieve this exact same magic using aggregate functions.

Summarizing Data with SQL Aggregates

SQL has built-in math superpowers called . They take a whole column of numbers from many different rows and condense them down into a single, summary value. Here are the three most common ones you'll use daily:
  • COUNT(): Counts how many rows match your search (like counting total transactions).
  • SUM(): Adds up all the values in a column (like calculating total revenue).
  • AVG(): Calculates the average value of a column (like finding the average spend per customer).

Let's see how simple this is to write. If Sarah wants to know the total number of orders in her database, we don't need to select all rows and count them manually. We can write this query:

SELECT COUNT(OrderID)
FROM Orders;

This query scans the Orders table, counts up every single OrderID it finds, and returns just one single number to your screen.

Now, let's try combining this with our WHERE filter! If Sarah only wants to know how many orders were placed for our high-cost drinks, we can filter first and then aggregate.

Continue to learn how to group aggregate data by categories using GROUP BY

I'm so glad we got those Excel spreadsheet calculations dialed in! Now that you have felt the power of summarizing data row-by-row, we are ready to take that exact same logic and apply it to database tables using SQL.

Grouping with GROUP BY

In our last step, we used a SUMIF formula to add up sales for a specific drink. But in SQL, we don't write a separate formula for every single product. Instead, we use the to automatically slice our data into categories.

When you use an aggregate function like COUNT(), SUM(), or AVG(), SQL wants to boil your whole table down to one single number. If you want to see those calculations broken down by category (like total sales per drink), you must tell SQL how to group them.

A GROUP BY operation aggregating eight raw drink records into a summary table of three unique drink counts.

The visualization above shows how SQL takes a scattered list of transactions and funnels them into a clean, aggregated summary.

Here is how we write this in a query:

SELECT DrinkID, COUNT(*) FROM Orders GROUP BY DrinkID;

This tells SQL to count up all the rows (COUNT(*)) but group those counts separately for each unique DrinkID.

This is identical to how we dragged Drink Name into the Rows area of our Excel PivotTable, and then dragged Total Revenue into the Values area!

Let's see how your SQL instincts handle this.

Imagine Sarah wants to see the total number of drinks sold for each menu item in her Orders table, but she wants them grouped by DrinkID.

Which of the following queries will successfully retrieve this categorized count?

Which SQL query correctly groups the count of orders by DrinkID?

SELECT DrinkID, COUNT(*) FROM Orders GROUP BY DrinkID;

You are absolutely on fire! Your calculation is flawless—when you run that query, SQL will collapse those 24 transaction rows down to three unique lines and show you the exact count for each drink, just like a PivotTable.

SQL
LV 1
Skills

The Spreadsheet to SQL Translation

To really cement this in your mind, let's look at how the SQL query you just wrote translates directly back to the we built for Sarah earlier. Seeing these two side-by-side reveals that you aren't actually learning a brand-new way of thinking—you are just translating your spreadsheet instincts into a new language.

Excel PivotTable StepEquivalent SQL ClausePurpose
Drag "DrinkID" into RowsGROUP BY DrinkIDIdentifies the unique categories to group by
Drag "OrderID" into Values (as Count)COUNT(*) or COUNT(OrderID)Calculates the aggregate summary for each category
Select the Source TableFROM OrdersPoints to the raw dataset being summarized

Every time you drag a field into the "Rows" box in Excel, you are telling the computer to perform a SQL GROUP BY behind the scenes. This connection is the ultimate secret weapon for spreadsheet analysts transitioning to databases. You already know how to analyze the data; you are just learning the keyboard commands to do it at a scale of billions of rows.

Now that you have seen how GROUP BY mirrors a PivotTable row, let's practice writing another query using a different aggregate function to summarize some financial metrics from our menu.

Continue to practice writing a GROUP BY query with SUM or AVG

I'm absolutely thrilled to see those spreadsheet formulas click! Now that you have felt the power of summarizing data in Excel, we're ready to take that exact same logical thinking and apply it to database tables using SQL.

Summarizing with SQL Aggregates

When we want to sum up or average numbers across multiple rows in SQL, we use . Just like Excel's SUM or AVERAGE formulas, these functions let us condense an entire column of data down to a single value.

To practice this, let's look at how we calculate things globally for Fuel & Foam. If Sarah wants to know the total revenue brought in across every single order in her database, we can write a simple query using the SUM() function. We tell SQL to multiply the UnitsSold by the Price for each row, and then add them all together like this:

SELECT SUM(UnitsSold * Price)
FROM Orders;

This query tells SQL to open the Orders table, multiply units by price on every row, sum up the grand total, and return one single number to our screen.

Using SUM and AVG with GROUP BY

But what if we don't want a single global total? What if we want to see the total revenue or average unit cost categorized for each unique drink?

This is where we combine our aggregate functions with a . Just like dragging "Drink Name" into the Rows area of an Excel PivotTable, adding GROUP BY DrinkID tells SQL to group our matching records together and calculate the sum or average for each category separately.

Let's see this in action. If we want to find the average cost of ingredients for each drink category in our Menu table, we can write our query using the AVG() function and group it by the drink name column:

SELECT DrinkName, AVG(UnitCost)
FROM Menu
GROUP BY DrinkName;

This query tells the database: "Group the rows by unique drink names, calculate the average unit cost for each of those groups, and show me the list."

Now, let's put your SQL analytical skills to the test with our practice scenario!

Sarah wants to calculate the Total Revenue generated by each individual drink on her menu. She wants the list to show the DrinkID alongside the sum of (UnitsSold * Price) from the Orders table, grouped by DrinkID. Which SQL query should she write?

SELECT DrinkID, SUM(UnitsSold * Price) FROM Orders GROUP BY DrinkID;

You are absolutely on fire! Your calculation is flawless: when you run that query, SQL collapses those 24 transaction rows down and shows you the exact revenue totals for each drink item, matching our target PivotTable perfectly.

SQL
LV 2
Skills

Sorting Grouped Results with ORDER BY

Now that we have successfully grouped and calculated our metrics, we face one final challenge. If Sarah's database has dozens or hundreds of different seasonal menu items, looking at a scattered list of totals makes it very hard to see which drinks are at the absolute top or bottom. We need a way to organize our output.

In Excel, you would simply right-click your PivotTable values and select Sort Largest to Smallest. In SQL, we do this using the .

The ORDER BY clause always goes at the very end of your query. By default, it sorts your results in ascending order (A to Z, or smallest to largest). If you want to sort in descending order (largest to smallest, which is perfect for finding your highest revenue or lowest cost outliers), you simply add the word DESC at the end.

Let's see this in action. If we want to sort our menu items by their unit cost, going from the most expensive to make to the cheapest, we write it like this:

SELECT DrinkName, UnitCost
FROM Menu
ORDER BY UnitCost DESC;

When you run this query, SQL gets the rows, evaluates the UnitCost for each item, and sorts the entire table so that the highest cost item is displayed first.

We can apply this exact same sorting logic to our grouped aggregate calculations. Let's see how your database instincts handle arranging our grouped coffee sales.

Let's continue to sorting our coffee revenue query

You are absolutely on fire today! Now that our coffee revenue query is grouped perfectly, we are ready to take the final step and sort those results using the .

To sort our summarized coffee shop revenues so Sarah can immediately spot her highest-earning drink, we just need to append our sorting rule to the very end of our grouped query.

We will sort by our calculated revenue column in descending order (DESC) so the biggest numbers appear first at the top of the list. Here is how that complete query looks:

SELECT DrinkID, SUM(UnitsSold * Price) AS TotalRevenue
FROM Orders
GROUP BY DrinkID
ORDER BY TotalRevenue DESC;

By using ORDER BY TotalRevenue DESC, SQL will automatically sort our three coffee items from highest total sales to lowest.

Now, let's flip this around to solve Sarah's actual business dilemma! To find the drink that is performing the worst and needs immediate attention, she wants to sort the query to show her lowest-revenue items first.

How should she modify the ORDER BY clause at the end of her query to sort the results from lowest revenue to highest?