Hiring Partners
Segilola Resources Operating LimitedTaviatech TechnologiesFCMBMTN NigeriaAdvans La Fayette Microfinance BankAboki AfricaFirst Bank of NigeriaOPay
โ† Power Query for Data Analysis ยท Lesson 11 of 17

Module Ten

๐Ÿ“– Every lesson in this course is free to read right here, no account needed. Create a free account to track your progress, take the exam, and earn your certificate.
11
Module 10 ยท Power Query for Data Analysis Expert

๐Ÿ”„ Module Ten: Pivot and Unpivot โ€“ Reshaping Data

Hello, young data explorer! Welcome to Module Ten. In this module, we will learn how to reshape our data. Sometimes data is in a "wide" format (many columns) and sometimes in a "long" format (many rows). We need to change from one to the other. This is called pivoting and unpivoting. Imagine you have a table where each month is a column. Unpivot turns those month columns into rows. Pivot does the opposite โ€“ it turns rows into columns. This helps us prepare data for charts and reports. By the end of this module, you will be a Data Reshaping Master!

๐ŸŽฏ Learning Objectives

  • Understand what pivot and unpivot mean.
  • Learn the difference between wide and long data.
  • Learn how to unpivot columns into rows.
  • Learn how to pivot rows into columns.
  • Learn how to use the "Unpivot Columns" feature.
  • Learn how to use the "Pivot Column" feature.
  • Understand when to use pivot and when to use unpivot.
  • Learn how to handle multiple value columns.
  • Learn how to rename pivoted columns.
  • Use pivot and unpivot for better analysis.

๐Ÿ“– Warm-up Story: The Monthly Sales Puzzle

Chidi has a sales table with months as columns: January, February, March. He wants to create a chart, but the chart expects months in a single column. So he unpivots the data โ€“ he turns the month columns into rows. Now he has a "Month" column and a "Sales" column. He can now make a beautiful chart. Later, his teacher wants a summary table with months as columns again. So he pivots the data back. That's the power of pivot and unpivot!

๐Ÿ“š Main Lessons (15 Lessons)

Lesson 1: What is Wide Data?

Definition: Wide data has many columns. Each column represents a different variable (e.g., Jan, Feb, Mar).

Why important: Wide data is easy to read for humans, but not always good for analysis.

Simple explanation: It's like a big table where each month has its own column.

Real-life example: A table with sales for each month as separate columns.

School example: A table with subjects as columns and student scores as rows.

Home example: A table with days of the week as columns and chores as rows.

Nigerian example: A table with states as columns and population as rows.

Illustration:

Wide Data (Months as columns)
+--------+-----+-----+-----+
| Product| Jan | Feb | Mar |
+--------+-----+-----+-----+
| Choco  | 100 | 150 | 200 |
| Lolly  | 50  | 60  | 70  |
+--------+-----+-----+-----+

Mini summary: Wide data has many columns.

Lesson 2: What is Long Data?

Definition: Long data has fewer columns but many rows. One column identifies the variable (e.g., Month), and another holds the value (e.g., Sales).

Why important: Long data is great for charts and analysis.

Simple explanation: It's like a tall table where months are in a single column.

Real-life example: A table with a "Month" column and a "Sales" column.

School example: A table with "Subject" and "Score" columns.

Home example: A table with "Day" and "Expense" columns.

Nigerian example: A table with "State" and "Population" columns.

Illustration:

Long Data (Month in one column)
+--------+-------+-------+
| Product| Month | Sales |
+--------+-------+-------+
| Choco  | Jan   | 100   |
| Choco  | Feb   | 150   |
| Choco  | Mar   | 200   |
| Lolly  | Jan   | 50    |
| Lolly  | Feb   | 60    |
| Lolly  | Mar   | 70    |
+--------+-------+-------+

Mini summary: Long data has few columns but many rows.

Lesson 3: What is Unpivot?

Definition: Unpivot turns columns into rows. It takes wide data and makes it long.

Why important: Unpivot prepares data for charts and analysis.

Simple explanation: It's like taking a wide table and stacking it into a tall table.

Real-life example: Turning monthly sales columns into a Month column and a Sales column.

School example: Turning subject columns into a Subject column and a Score column.

Home example: Turning day columns into a Day column and a Chore column.

Nigerian example: Turning state columns into a State column and a Population column.

How to do it: Select the columns you want to unpivot, right-click, and choose "Unpivot Columns".

Illustration:

Wide โ†’ Unpivot โ†’ Long
+--------+-----+-----+-----+   +--------+-------+-------+
| Product| Jan | Feb | Mar |   | Product| Month | Sales |
+--------+-----+-----+-----+   +--------+-------+-------+
| Choco  | 100 | 150 | 200 |   | Choco  | Jan   | 100   |
| Lolly  | 50  | 60  | 70  |   | Choco  | Feb   | 150   |
+--------+-----+-----+-----+   | Choco  | Mar   | 200   |
                                | Lolly  | Jan   | 50    |
                                | Lolly  | Feb   | 60    |
                                | Lolly  | Mar   | 70    |
                                +--------+-------+-------+

Mini summary: Unpivot turns columns into rows.

Lesson 4: How to Unpivot in Power Query

Definition: In Power Query, you can unpivot by selecting columns and using the "Unpivot Columns" option.

Why important: This is the main way to reshape data in Power Query.

Simple explanation: It's like clicking a button to change a wide table into a long table.

Real-life example: You have a table with months as columns. You unpivot to get a Month column.

School example: You have a table with subjects as columns. You unpivot to get a Subject column.

Home example: You have a table with days as columns. You unpivot to get a Day column.

Nigerian example: You have a table with states as columns. You unpivot to get a State column.

How to do it: Select the columns (e.g., Jan, Feb, Mar) โ†’ right-click โ†’ Unpivot Columns.

Illustration:

Select Jan, Feb, Mar โ†’ Right-click โ†’ Unpivot Columns

Mini summary: Use Unpivot Columns to turn columns into rows.

Lesson 5: Unpivot Other Columns (Keep Some Columns)

Definition: You can unpivot some columns while keeping others as identifiers (e.g., Product).

Why important: You often want to keep some columns as "keys" while unpivoting others.

Simple explanation: You keep the "Product" column as is, and unpivot the month columns.

Real-life example: Keep Product and Region, unpivot monthly sales.

School example: Keep Student Name, unpivot subject scores.

Home example: Keep Family Member, unpivot daily chores.

Nigerian example: Keep LGA, unpivot monthly rainfall.

How to do it: Select the columns to unpivot, right-click, and choose "Unpivot Columns". The other columns stay as identifiers.

Illustration:

Keep Product, unpivot Jan, Feb, Mar.
Result: Product, Attribute (Month), Value (Sales).

Mini summary: Unpivot specific columns while keeping others as identifiers.

Lesson 6: What is Pivot?

Definition: Pivot turns rows into columns. It takes long data and makes it wide.

Why important: Pivot helps create summary tables that are easy to read.

Simple explanation: It's like taking a tall table and spreading it out into a wide table.

Real-life example: Turning a Month column into separate columns for each month.

School example: Turning a Subject column into separate columns for each subject.

Home example: Turning a Day column into separate columns for each day.

Nigerian example: Turning a State column into separate columns for each state.

How to do it: In Power Query, select the column you want to pivot, go to Transform, and click "Pivot Column".

Illustration:

Long โ†’ Pivot โ†’ Wide
+--------+-------+-------+   +--------+-----+-----+-----+
| Product| Month | Sales |   | Product| Jan | Feb | Mar |
+--------+-------+-------+   +--------+-----+-----+-----+
| Choco  | Jan   | 100   |   | Choco  | 100 | 150 | 200 |
| Choco  | Feb   | 150   |   | Lolly  | 50  | 60  | 70  |
| Choco  | Mar   | 200   |   +--------+-----+-----+-----+
| Lolly  | Jan   | 50    |
| Lolly  | Feb   | 60    |
| Lolly  | Mar   | 70    |
+--------+-------+-------+

Mini summary: Pivot turns rows into columns.

Lesson 7: How to Pivot in Power Query

Definition: In Power Query, you pivot using the "Pivot Column" feature.

Why important: This is the main way to make wide tables from long tables.

Simple explanation: You choose a column whose values will become new columns.

Real-life example: You have a Month column. Pivot it to get columns for each month.

School example: You have a Subject column. Pivot it to get columns for each subject.

Home example: You have a Day column. Pivot it to get columns for each day.

Nigerian example: You have a State column. Pivot it to get columns for each state.

How to do it: Select the column to pivot (e.g., Month) โ†’ Transform โ†’ Pivot Column โ†’ Choose the values column (e.g., Sales).

Illustration:

Select Month โ†’ Pivot Column โ†’ Values: Sales โ†’ OK

Mini summary: Use Pivot Column to turn rows into columns.

Lesson 8: Pivot with Multiple Value Columns

Definition: You can pivot with more than one value column (e.g., Sales and Quantity).

Why important: Sometimes you need to pivot multiple measures.

Simple explanation: You can have both Sales and Quantity as values.

Real-life example: Pivot Month to get Sales and Quantity columns.

School example: Pivot Subject to get Score and Attendance.

Home example: Pivot Day to get Expenses and Calories.

Nigerian example: Pivot Year to get Population and GDP.

How to do it: In Pivot dialog, select "Advanced" and add multiple value columns.

Illustration:

Pivot Month, Values: Sales, Quantity
Result: Jan_Sales, Jan_Qty, Feb_Sales, Feb_Qty, ...

Mini summary: Pivot can handle multiple value columns.

Lesson 9: Unpivot vs Pivot โ€“ When to Use Each

Definition: Unpivot makes data longer (more rows). Pivot makes data wider (more columns).

Why important: Choosing the right one depends on your goal.

Simple explanation: Unpivot when you need data for charts. Pivot when you need summary tables.

Real-life example: Unpivot for a line chart. Pivot for a summary report.

School example: Unpivot to compare scores. Pivot to show scores per subject.

Home example: Unpivot to track daily habits. Pivot to see weekly totals.

Nigerian example: Unpivot to analyze monthly trends. Pivot to show state-wise data.

Illustration:

Unpivot: Wide โ†’ Long (for charts)
Pivot:   Long โ†’ Wide (for summary)

Mini summary: Unpivot for analysis, Pivot for presentation.

Lesson 10: Renaming Pivot Columns

Definition: After pivoting, you may want to rename the new columns.

Why important: To make column names clear and meaningful.

Simple explanation: Change "Jan" to "January Sales".

Real-life example: Rename "Jan" to "Jan-2025".

School example: Rename "Math" to "Math Score".

Home example: Rename "Monday" to "Monday Chores".

Nigerian example: Rename "Lagos" to "Lagos Population".

How to do it: Double-click the column header and type the new name.

Illustration:

Before: "Jan"   After: "January Sales"

Mini summary: Rename pivoted columns for clarity.

Lesson 11: Unpivot with Multiple Identifier Columns

Definition: You can keep multiple columns as identifiers when unpivoting.

Why important: Sometimes you need to keep more than one key column.

Simple explanation: Keep Product and Region, unpivot months.

Real-life example: Keep Product and Region, unpivot monthly sales.

School example: Keep Student and Class, unpivot subject scores.

Home example: Keep Family Member and Day, unpivot meals.

Nigerian example: Keep State and LGA, unpivot monthly rainfall.

How to do it: Select the columns to unpivot, the others stay as identifiers.

Illustration:

Identifiers: Product, Region   Unpivot: Jan, Feb, Mar
Result: Product, Region, Month, Sales

Mini summary: You can have multiple identifier columns when unpivoting.

Lesson 12: Pivot with Advanced Options

Definition: Pivot has advanced options like aggregating values (e.g., Sum, Average).

Why important: If there are duplicate values, you need to aggregate.

Simple explanation: If you have two sales for the same month, sum them.

Real-life example: Sum sales for each month-product combination.

School example: Average scores for each subject-student combination.

Home example: Sum expenses for each day-category combination.

Nigerian example: Sum population for each state-LGA combination.

How to do it: In Pivot dialog, choose "Advanced" and select an aggregation.

Illustration:

Pivot Month, Values: Sales, Aggregation: Sum

Mini summary: Use advanced pivot options for aggregating.

Lesson 13: Unpivot โ€“ Handling Errors

Definition: Sometimes unpivot fails if columns have different data types.

Why important: To avoid errors, ensure all columns have the same data type.

Simple explanation: Make sure all month columns are numbers or all are text.

Real-life example: Jan is number, Feb is text โ€“ error. Fix by changing types.

School example: Math is number, English is text โ€“ error. Fix.

Home example: Monday is number, Tuesday is text โ€“ error. Fix.

Nigerian example: Lagos is number, Abuja is text โ€“ error. Fix.

How to fix: Change all columns to the same data type before unpivoting.

Illustration:

Before: Jan (number), Feb (text) โ†’ Error
Fix: Change both to number โ†’ Unpivot works.

Mini summary: Ensure columns have the same data type before unpivoting.

Lesson 14: Combining Pivot and Unpivot

Definition: You can pivot and then unpivot, or vice versa, to reshape data.

Why important: Sometimes you need multiple transformations.

Simple explanation: You might unpivot, clean data, then pivot back.

Real-life example: Unpivot to fix data, then pivot to create summary.

School example: Unpivot to analyze, then pivot to present.

Home example: Unpivot to track, then pivot to report.

Nigerian example: Unpivot for trends, then pivot for comparison.

Illustration:

Wide โ†’ Unpivot โ†’ Clean โ†’ Pivot โ†’ Wide (clean version)

Mini summary: Combine pivot and unpivot for powerful reshaping.

Lesson 15: Best Practices for Pivot and Unpivot

Definition: Tips to use pivot and unpivot effectively.

Why important: To avoid errors and get the desired shape.

Simple explanation: Like following a recipe for perfect cookies.

  • Before unpivoting, ensure all columns have the same data type.
  • Choose the right identifier columns.
  • Rename columns after pivoting.
  • Use advanced aggregation if needed.
  • Test with a small sample first.

Illustration:

1. Check data types
2. Select identifiers
3. Choose pivot/unpivot
4. Rename columns
5. Verify result

Mini summary: Follow best practices for smooth reshaping.

๐Ÿ“– Key Vocabulary (with simple definitions)

  • Wide Data: Data with many columns.
  • Long Data: Data with many rows.
  • Unpivot: Turn columns into rows.
  • Pivot: Turn rows into columns.
  • Identifier: A column that stays as is (like Product).
  • Value Column: The column that contains the numbers (like Sales).
  • Attribute Column: The column created by unpivot that holds the original column names (like Month).

๐Ÿง  Important Concepts

  • Unpivot makes data longer (good for charts).
  • Pivot makes data wider (good for reports).
  • Identifiers are columns you keep.
  • Value columns are the data you pivot/unpivot.

๐Ÿ”ข Step-by-Step Explanations

How to Unpivot Data:

  1. Load your wide data into Power Query.
  2. Select the columns you want to unpivot (e.g., Jan, Feb, Mar).
  3. Right-click and choose "Unpivot Columns".
  4. You will get an "Attribute" column (the original column names) and a "Value" column (the numbers).
  5. Rename Attribute to "Month" and Value to "Sales".

How to Pivot Data:

  1. Load your long data into Power Query.
  2. Select the column that will become the new columns (e.g., Month).
  3. Go to Transform โ†’ Pivot Column.
  4. Choose the Values column (e.g., Sales).
  5. Choose aggregation if needed (e.g., Sum).
  6. Click OK. Now you have a wide table.

๐ŸŒ Real-life Examples

  • Retail: Unpivot monthly sales for trend analysis.
  • Healthcare: Pivot patient data to show vitals per day.
  • Education: Unpivot subject scores to calculate average.

๐Ÿ‡ณ๐Ÿ‡ฌ Nigerian Examples

  • Election: Unpivot party votes to compare trends.
  • Agriculture: Pivot crop yields by state for comparison.
  • Telecom: Unpivot monthly call data for analysis.

๐ŸŽˆ Fun Examples Children Can Relate To

  • Toys: Unpivot a table of toy sales by month to see trends.
  • Candy: Pivot a candy sales table to show each candy in its own column.
  • Games: Unpivot scores from different games to compare.

๐Ÿ  Everyday Examples

  • Budget: Unpivot monthly expenses to see trends.
  • Chores: Pivot chores by day to see weekly schedule.
  • School: Unpivot subject grades to calculate GPA.

๐Ÿ‘ฉโ€๐Ÿซ Teacher Notes

  • Use real examples like student grades in wide format.
  • Show how unpivoting helps create charts.
  • Emphasize that pivot and unpivot are opposites.

๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘ฆ Parent Tips

  • Help your child turn a wide table (like a calendar) into a long table.
  • Discuss how reshaping helps in organizing information.

๐Ÿ’ก Interesting Facts

  • Pivot and unpivot are also called "transpose" in some tools.
  • Power Query can pivot and unpivot millions of rows quickly.
  • Unpivoting is often the first step in data cleaning.

โ“ Did You Know?

Did you know that the term "pivot" comes from sports โ€“ pivoting means turning around a fixed point. In data, you turn rows into columns!

๐Ÿ”” Remember This

  • Unpivot = columns โ†’ rows (makes data longer).
  • Pivot = rows โ†’ columns (makes data wider).
  • Choose the right operation for your goal.
  • Always check data types before unpivoting.

โš ๏ธ Common Mistakes

  • Forgetting to change data types before unpivoting (causes errors).
  • Pivoting without aggregation when there are duplicates (causes errors).
  • Not renaming columns after pivoting (confusing names).
  • Unpivoting the wrong columns (losing important identifiers).

โœ… Best Practices

  • Check data types before unpivoting.
  • Choose the right identifiers.
  • Use aggregation when pivoting with duplicates.
  • Rename columns for clarity.

๐Ÿ“Š ASCII Illustrations

Unpivot Process

  Wide Data
+--------+-----+-----+-----+
| Product| Jan | Feb | Mar |
+--------+-----+-----+-----+
| Choco  | 100 | 150 | 200 |
| Lolly  | 50  | 60  | 70  |
+--------+-----+-----+-----+
          |
          V
     Unpivot
          |
          V
  Long Data
+--------+-------+-------+
| Product| Month | Sales |
+--------+-------+-------+
| Choco  | Jan   | 100   |
| Choco  | Feb   | 150   |
| Choco  | Mar   | 200   |
| Lolly  | Jan   | 50    |
| Lolly  | Feb   | 60    |
| Lolly  | Mar   | 70    |
+--------+-------+-------+

Pivot Process

  Long Data
+--------+-------+-------+
| Product| Month | Sales |
+--------+-------+-------+
| Choco  | Jan   | 100   |
| Choco  | Feb   | 150   |
| Choco  | Mar   | 200   |
| Lolly  | Jan   | 50    |
| Lolly  | Feb   | 60    |
| Lolly  | Mar   | 70    |
+--------+-------+-------+
          |
          V
      Pivot
          |
          V
  Wide Data
+--------+-----+-----+-----+
| Product| Jan | Feb | Mar |
+--------+-----+-----+-----+
| Choco  | 100 | 150 | 200 |
| Lolly  | 50  | 60  | 70  |
+--------+-----+-----+-----+

๐Ÿ“‹ Comparison Tables

Wide vs Long Data

FeatureWideLong
Number of columnsManyFew
Number of rowsFewMany
Best forReports, human readingCharts, analysis

Pivot vs Unpivot

OperationDirectionResult
UnpivotColumns โ†’ RowsLonger data
PivotRows โ†’ ColumnsWider data

๐Ÿ“ End-of-Module Summary

Congratulations! You have completed Module Ten on Pivot and Unpivot. You learned:

  • The difference between wide and long data.
  • How to unpivot columns into rows.
  • How to pivot rows into columns.
  • When to use each operation.
  • How to handle multiple identifiers and value columns.
  • Best practices to avoid errors.

Pivot and unpivot are powerful tools to reshape data. Now you can transform any data into the perfect shape for your analysis or report!

โ“ Frequently Asked Questions (10)

  1. What is wide data? โ€“ Data with many columns.
  2. What is long data? โ€“ Data with many rows.
  3. What is unpivot? โ€“ Turning columns into rows.
  4. What is pivot? โ€“ Turning rows into columns.
  5. When should I unpivot? โ€“ When you need data for charts or analysis.
  6. When should I pivot? โ€“ When you need a summary table.
  7. What is an identifier? โ€“ A column you keep as is (like Product).
  8. What is a value column? โ€“ The column with the numbers (like Sales).
  9. Why do I need to check data types before unpivoting? โ€“ To avoid errors.
  10. Can I pivot with multiple value columns? โ€“ Yes, using advanced options.

๐Ÿ“ Review Questions (15)

  1. What is wide data?
  2. What is long data?
  3. What does unpivot do?
  4. What does pivot do?
  5. Give an example of wide data.
  6. Give an example of long data.
  7. When would you use unpivot?
  8. When would you use pivot?
  9. What is an identifier in unpivot?
  10. What is a value column in pivot?
  11. Why should you check data types before unpivoting?
  12. How do you rename columns after pivoting?
  13. What is the "Attribute" column in unpivot?
  14. Can you have multiple identifiers in unpivot?
  15. What is the opposite of unpivot?

โœ๏ธ Fill-in-the-Blank Exercises

  1. ______ data has many columns.
  2. ______ data has many rows.
  3. ______ turns columns into rows.
  4. ______ turns rows into columns.
  5. In unpivot, the column that holds the original column names is called ______.

โœ… True or False Exercises

  1. Wide data has many rows. (False)
  2. Unpivot makes data longer. (True)
  3. Pivot makes data wider. (True)
  4. You don't need to check data types before unpivoting. (False)
  5. Pivot and unpivot are opposites. (True)

๐Ÿ”˜ Multiple Choice Questions (15 with answers)

  1. Which operation turns columns into rows?
    a) Pivot b) Unpivot c) Merge d) Append
    Answer: b
  2. Which operation turns rows into columns?
    a) Pivot b) Unpivot c) Merge d) Append
    Answer: a
  3. What is wide data?
    a) Many columns b) Many rows c) Few columns d) Few rows
    Answer: a
  4. What is long data?
    a) Many columns b) Many rows c) Few columns d) Few rows
    Answer: b
  5. In unpivot, what are the columns you keep called?
    a) Identifiers b) Values c) Attributes d) Measures
    Answer: a
  6. In pivot, what is the column with the numbers called?
    a) Identifier b) Value c) Attribute d) Key
    Answer: b
  7. Why check data types before unpivoting?
    a) To avoid errors b) To make it faster c) To rename columns d) To sort data
    Answer: a
  8. What is the opposite of unpivot?
    a) Merge b) Append c) Pivot d) Split
    Answer: c
  9. Which is best for charts?
    a) Wide b) Long c) Both d) Neither
    Answer: b
  10. Which is best for summary reports?
    a) Wide b) Long c) Both d) Neither
    Answer: a
  11. What is the "Attribute" column in unpivot?
    a) The numbers b) The original column names c) The identifiers d) The totals
    Answer: b
  12. Can you have multiple identifiers in unpivot?
    a) Yes b) No c) Only if they are numbers d) Only if they are text
    Answer: a
  13. Can you pivot with multiple value columns?
    a) Yes b) No c) Only with advanced options d) Only with text
    Answer: a
  14. What happens if you pivot without aggregation when there are duplicates?
    a) Error b) It works fine c) It sums d) It averages
    Answer: a
  15. What is the first step when unpivoting?
    a) Rename columns b) Check data types c) Sort data d) Merge data
    Answer: b

๐Ÿ”— Matching Exercises

Match the term to its description:

TermDescription
1. Wide DataA. Many rows
2. Long DataB. Many columns
3. UnpivotC. Rows to columns
4. PivotD. Columns to rows

Answers: 1-B, 2-A, 3-D, 4-C

โœ๏ธ Short Answer Questions

  1. Explain the difference between wide and long data.
  2. What is unpivot and when would you use it?
  3. What is pivot and when would you use it?
  4. Why is it important to check data types before unpivoting?
  5. Give an example of a pivot operation in real life.

๐Ÿ“– Scenario-based Exercises

Scenario 1: You have a table with months as columns (Jan, Feb, Mar) and products as rows. You want to create a line chart showing sales by month. How would you reshape the data? Write the steps.

Scenario 2: You have a table with a "Month" column and a "Sales" column. You want to present it as a summary table with months as columns. How would you do it? Write the steps.

๐Ÿ‘ฅ Group Activity

In groups, get a wide dataset (e.g., sales by month). Unpivot it to long format, then pivot it back to wide. Discuss why you might need to do each operation.

๐Ÿง‘โ€๐ŸŽ“ Individual Activity

Create a small wide table (e.g., with months as columns). Use Power Query to unpivot it. Then rename the columns to "Month" and "Sales".

๐Ÿ’ฌ Classroom Discussion Questions

  • Why is unpivoting important for creating charts?
  • How does pivoting help in reporting?
  • Can you think of a situation where you would need to do both?

๐Ÿ› ๏ธ Mini Project

Project: Reshape School Data

You have a wide table of student scores: Student, Math, English, Science, Art. Unpivot the subject columns to create a long table. Then pivot it back to wide, but with subjects as rows and students as columns. Compare the two formats.

๐Ÿ“‹ Practical Assignment

Download a sample dataset with months as columns (e.g., sales data). Use Power Query to unpivot it. Then create a pivot table in Excel based on the unpivoted data. Submit both the unpivoted table and the pivot table.

๐Ÿ† Challenge Exercise

You have a dataset with columns: Product, Year, Quarter, Sales. Pivot the Quarter column to get columns for Q1, Q2, Q3, Q4. Then unpivot the year columns to get a Year column. This is a double transformation โ€“ pivot and then unpivot.

๐Ÿ“ Quiz Answers

Fill-in-the-Blank: 1. Wide, 2. Long, 3. Unpivot, 4. Pivot, 5. Attribute

True/False: 1-F, 2-T, 3-T, 4-F, 5-T

Matching: 1-B, 2-A, 3-D, 4-C

๐Ÿ”‘ Key Takeaways

  • Wide data = many columns. Long data = many rows.
  • Unpivot = columns โ†’ rows (makes data longer).
  • Pivot = rows โ†’ columns (makes data wider).
  • Unpivot is great for charts and analysis.
  • Pivot is great for summary tables.
  • Always check data types before unpivoting.
  • Rename columns for clarity.

๐Ÿ“– Preparation for the Next Module

In Module Eleven, we will learn about Advanced Data Transformation โ€“ combining multiple techniques to solve complex problems. We will use all the skills from previous modules to clean, combine, group, and reshape data like true experts. Get ready to become a Power Query Master!

Before the next class, practice unpivoting and pivoting with different datasets. Try to create both a chart and a report from the same data.


ยฉ 2025 Certified Power Query for Data Analysis Expert โ€“ Module Ten

๐Ÿ† Get Certified

๐Ÿ”’

Earn this certificate

Every lesson is already free to read. Sign up, finish the lessons, pass the exam (โ‚ฆ2,000 or 20,000 coins), and get a verified certificate with your name on it.

๐ŸŽ“ Sign Up to Get Certified
๐Ÿ› ๏ธ Practice Tools
Hands-on simulators & labs - subscription required.
โ†’
๐ŸŽฏ Internship Tasks
Real-world tasks to build your portfolio - unlock them with a subscription.
โ†’