Bird
Raised Fist0
Power BIbi_tool~15 mins

Unpivoting columns in Power BI - Real Business Scenario

Choose your learning style10 modes available
Scenario Mode
👤 Your Role: You are a sales analyst at a retail company.
📋 Request: Your manager wants to analyze monthly sales data by product category. The data is currently in a wide format with months as columns. You need to transform it into a long format for better analysis.
📊 Data: You have a table showing sales amounts for three product categories (Electronics, Clothing, Home Goods) across three months (January, February, March). Each month is a separate column.
🎯 Deliverable: Create a Power BI query that unpivots the monthly sales columns into two columns: 'Month' and 'Sales'. Then build a simple bar chart showing total sales by month.
Progress0 / 6 steps
Sample Data
Product CategoryJanuaryFebruaryMarch
Electronics120001500013000
Clothing800070009000
Home Goods500060005500
1
Step 1: Load the sales data table into Power BI Desktop using 'Get Data'.
Use 'Excel' or 'CSV' depending on your file format and load the table.
Expected Result
The sales data table appears in Power BI's Power Query Editor.
2
Step 2: Select the columns for the months (January, February, March) to unpivot.
In Power Query Editor, select columns 'January', 'February', and 'March'.
Expected Result
The three month columns are highlighted for transformation.
3
Step 3: Unpivot the selected month columns to transform them into attribute-value pairs.
Right-click on the selected columns and choose 'Unpivot Columns'.
Expected Result
The table now has columns: 'Product Category', 'Attribute', and 'Value'. 'Attribute' contains month names, 'Value' contains sales amounts.
4
Step 4: Rename the 'Attribute' column to 'Month' and the 'Value' column to 'Sales'.
Double-click column headers and rename accordingly.
Expected Result
Columns are named 'Product Category', 'Month', and 'Sales'.
5
Step 5: Close and apply the query changes to load the transformed data into Power BI.
Click 'Close & Apply' in Power Query Editor.
Expected Result
The transformed data is loaded into Power BI's data model.
6
Step 6: Create a bar chart visual to show total sales by month.
In the report view, add a bar chart visual. Drag 'Month' to Axis and 'Sales' to Values (set aggregation to SUM).
Expected Result
A bar chart displays total sales for January, February, and March.
Final Result
Sales by Month Bar Chart

January  | ██████████████ 25000
February | ██████████████████ 28000
March    | ████████████████ 27500

(Product categories combined)
✓February had the highest total sales across all product categories.
✓January had the lowest total sales.
✓Unpivoting the data made it easy to compare sales by month.
Bonus Challenge

Create a slicer to filter the bar chart by 'Product Category' so you can see monthly sales for each category separately.

Show Hint
Add a slicer visual, drag 'Product Category' to it, and interact with the bar chart.

Practice

(1/5)
1. What does unpivoting columns in Power BI do?
easy
A. It merges multiple tables into one table.
B. It filters rows based on column values.
C. It creates new calculated columns based on existing data.
D. It converts multiple columns into rows to simplify analysis.

Solution

  1. Step 1: Understand the purpose of unpivoting

    Unpivoting changes the data layout by turning columns into rows, making repeated measures easier to analyze.
  2. Step 2: Compare with other operations

    Merging tables combines tables, calculated columns add new data, and filtering removes rows, which are different from unpivoting.
  3. Final Answer:

    It converts multiple columns into rows to simplify analysis. -> Option D
  4. Quick Check:

    Unpivoting = Columns to rows [OK]
Hint: Unpivoting flips columns into rows for easier data analysis [OK]
Common Mistakes:
  • Confusing unpivoting with merging tables
  • Thinking unpivoting creates new columns
  • Assuming unpivoting filters data
2. Which step correctly describes how to unpivot columns in Power Query Editor?
easy
A. Select the columns to unpivot, right-click, and choose 'Unpivot Columns'.
B. Select the columns, then click 'Merge Queries'.
C. Select the columns, then click 'Add Column' > 'Custom Column'.
D. Select the columns, then click 'Remove Columns'.

Solution

  1. Step 1: Identify the unpivot action in Power Query

    Unpivoting is done by selecting columns, right-clicking, and choosing 'Unpivot Columns'.
  2. Step 2: Differentiate from other options

    'Merge Queries' combines tables, 'Add Column' creates new columns, and 'Remove Columns' deletes columns, none unpivot data.
  3. Final Answer:

    Select the columns to unpivot, right-click, and choose 'Unpivot Columns'. -> Option A
  4. Quick Check:

    Unpivot = Right-click > Unpivot Columns [OK]
Hint: Right-click selected columns and pick 'Unpivot Columns' [OK]
Common Mistakes:
  • Choosing 'Merge Queries' instead of unpivot
  • Trying to add a custom column to unpivot
  • Removing columns instead of unpivoting
3. Given this table before unpivoting:
Product | Jan | Feb | Mar
--------|-----|-----|----
A       | 10  | 15  | 20
B       | 5   | 7   | 8

What will be the result after unpivoting the Jan, Feb, Mar columns?
medium
A.
Product | Month | Sales
--------|-------|------
Jan     | A     | 10
Feb     | A     | 15
Mar     | A     | 20
Jan     | B     | 5
Feb     | B     | 7
Mar     | B     | 8
B.
Product | Jan | Feb | Mar
--------|-----|-----|----
A       | 10  | 15  | 20
B       | 5   | 7   | 8
C.
Product | Attribute | Value
--------|-----------|------
A       | Jan       | 10
A       | Feb       | 15
A       | Mar       | 20
B       | Jan       | 5
B       | Feb       | 7
B       | Mar       | 8
D.
Product | Value
--------|------
A       | 10
A       | 15
A       | 20
B       | 5
B       | 7
B       | 8

Solution

  1. Step 1: Understand unpivot output structure

    Unpivoting converts columns Jan, Feb, Mar into rows under a new 'Attribute' column, with their values in 'Value'.
  2. Step 2: Match the correct table format

    Product | Attribute | Value
    --------|-----------|------
    A       | Jan       | 10
    A       | Feb       | 15
    A       | Mar       | 20
    B       | Jan       | 5
    B       | Feb       | 7
    B       | Mar       | 8
    shows Product repeated with each month as 'Attribute' and corresponding values, which matches unpivot output.
  3. Final Answer:

    Table with columns Product, Attribute, Value listing each month as a row. -> Option C
  4. Quick Check:

    Unpivot = Columns to Attribute-Value rows [OK]
Hint: Unpivot creates Attribute and Value columns from selected columns [OK]
Common Mistakes:
  • Thinking unpivot keeps original columns
  • Dropping the attribute column
  • Swapping row and column values incorrectly
4. You tried to unpivot columns in Power Query but the 'Unpivot Columns' option is greyed out. What is the most likely cause?
medium
A. You are in the Data view instead of Power Query Editor.
B. You have not selected any columns to unpivot.
C. Your data contains blank rows.
D. Your table has too many columns.

Solution

  1. Step 1: Check selection requirement for unpivot

    The 'Unpivot Columns' option requires at least one column selected; otherwise, it is disabled.
  2. Step 2: Eliminate other causes

    Blank rows or table size do not disable the option; being outside Power Query Editor means the option is not visible, not greyed out.
  3. Final Answer:

    No columns selected to unpivot. -> Option B
  4. Quick Check:

    Unpivot disabled if no columns selected [OK]
Hint: Always select columns before unpivoting [OK]
Common Mistakes:
  • Ignoring the need to select columns
  • Confusing Power Query Editor with Data view
  • Assuming blank rows disable unpivot
5. You have sales data with columns: Region, Product, Q1, Q2, Q3, Q4. You want to analyze quarterly sales trends by region and product. Which is the best approach?
hard
A. Unpivot the Q1, Q2, Q3, Q4 columns to create a 'Quarter' and 'Sales' column.
B. Merge the Q1 to Q4 columns into one column using concatenation.
C. Create calculated columns for each quarter's sales growth.
D. Filter the data to show only Q1 and Q2 sales.

Solution

  1. Step 1: Identify the need for unpivoting

    Quarterly sales are spread across columns Q1 to Q4; unpivoting these columns will convert them into rows with 'Quarter' and 'Sales' columns, enabling trend analysis.
  2. Step 2: Evaluate other options

    Merging columns concatenates data, which is not useful for numeric analysis; calculated columns for growth require unpivoted data first; filtering limits data and does not reshape it.
  3. Final Answer:

    Unpivot the Q1, Q2, Q3, Q4 columns to create a 'Quarter' and 'Sales' column. -> Option A
  4. Quick Check:

    Unpivot quarterly columns for trend analysis [OK]
Hint: Unpivot repeated measure columns for time series analysis [OK]
Common Mistakes:
  • Trying to merge numeric columns as text
  • Skipping unpivot before calculating growth
  • Filtering instead of reshaping data
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard