Power Query – Power Pivot Overview: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
== Objective == | == Objective == | ||
Learn how to load | Learn how to load multiple related tables into the Data Model using Power Query, create relationships in Power Pivot, and build PivotTables using DAX calculations. | ||
== Files Used == | == Files Used == | ||
* [[Media: | * [[Media:PowerPivot_Customers.xlsx|Download PowerPivot_Customers.xlsx]] | ||
* [[Media:PowerPivot_Products.xlsx|Download PowerPivot_Products.xlsx]] | |||
* [[Media:PowerPivot_Sales.xlsx|Download PowerPivot_Sales.xlsx]] | |||
== Enabling Power Pivot == | == Enabling Power Pivot Add-in == | ||
'''Steps:''' | '''Steps:''' | ||
# | # Open Excel. | ||
# Go to the '''File''' tab → click '''Options'''. | |||
# In the Excel Options window | # In the Excel Options window → select '''Add-ins'''. | ||
# At the bottom, | # At the bottom, next to '''Manage''', select '''COM Add-ins''' from the dropdown → click '''Go...'''. | ||
# In the list, check '''Microsoft Power Pivot for Excel''' → click '''OK'''. | |||
# In the | # The '''Power Pivot''' tab will now appear in the ribbon. | ||
# The '''Power Pivot''' tab | |||
== | == Importing Data via Power Query into the Data Model == | ||
'''Steps:''' | '''Steps:''' | ||
# | # Go to the '''Data''' tab → click '''Get Data''' → '''From File''' → '''From Workbook'''. | ||
# Select | # Select and open '''PowerPivot_Customers.xlsx'''. | ||
# In | # In Navigator → check the sheet → click '''Transform Data'''. | ||
# In Power Query Editor | # In Power Query Editor → click the '''Home''' tab → click the dropdown under '''Close & Load''' → choose '''Close & Load To...'''. | ||
# In | # In Import Data dialog: | ||
#* Select '''Only Create Connection''' | #* Select '''Only Create Connection''' | ||
#* Check the box | #* Check the box '''Add this data to the Data Model''' | ||
# Click '''OK''' | #* Click '''OK''' | ||
# | # Repeat these steps for '''PowerPivot_Products.xlsx''' and '''PowerPivot_Sales.xlsx'''. | ||
== Opening the Power Pivot Window == | == Opening the Power Pivot Window == | ||
'''Steps:''' | '''Steps:''' | ||
# | # Go to the Excel ribbon → click on the '''Power Pivot''' tab. | ||
# Click | # Click '''Manage'''. | ||
# The Power Pivot window will open | # The Power Pivot window will open showing the loaded tables. | ||
== Creating Relationships == | == Creating Relationships Between Tables == | ||
'''Steps:''' | '''Steps:''' | ||
# In the Power Pivot window | # In the Power Pivot window → click the '''Diagram View''' button in the top-right. | ||
# | # Drag from '''CustomerID''' in the Sales table to '''CustomerID''' in the Customers table. | ||
# Drag from '''ProductID''' in the Sales table to '''ProductID''' in the Products table. | |||
# | # You should now see the relationships as arrows between the tables. | ||
# | |||
== Creating a DAX Measure == | == Creating a DAX Measure == | ||
'''Steps:''' | '''Steps:''' | ||
# In the Power Pivot window | # In the Power Pivot window → click on the '''Sales''' table. | ||
# Scroll to the bottom of the | # Scroll to the bottom of the table. | ||
# | # In the empty cell under the data → type the formula: | ||
Total | Total Sales := SUM([Total]) | ||
# Press '''Enter'''. | # Press '''Enter'''. | ||
# The measure | # The measure is now available in PivotTables. | ||
== | == Building a PivotTable from the Data Model == | ||
'''Steps:''' | '''Steps:''' | ||
# In Excel | # In Excel → go to the '''Insert''' tab → click '''PivotTable'''. | ||
# In Create PivotTable dialog: | |||
# In | #* Select '''Use this workbook’s Data Model''' | ||
#* Select | #* Choose location (New worksheet or Existing worksheet) | ||
#* Choose | # Click '''OK''' | ||
# Click '''OK''' | # Use fields from all related tables: | ||
# | #* Add `Region` from Customers to Rows | ||
# | #* Add `Category` from Products to Columns | ||
#* Add `Total Sales` to Values | |||
== Additional Exercise: | == Additional Exercise: Analyze by Region and Product == | ||
'''Goal:''' Analyze | '''Goal:''' Analyze total sales by region and product category. | ||
'''Steps:''' | '''Steps:''' | ||
# | # Create a PivotTable based on the Data Model. | ||
# | # Add `Region` (Customers) to Rows. | ||
# Add `Category` (Products) to Columns. | |||
# | # Add `Total Sales` measure to Values. | ||
# | # Optional: Apply formatting or sort highest to lowest. | ||
== Extension: Add a Calculated Column in Power Pivot == | |||
'''Steps:''' | '''Steps:''' | ||
# In the Power Pivot window → | # In the Power Pivot window → select the '''Sales''' table. | ||
# Scroll to the rightmost column → click into the empty column labeled '''Add Column'''. | # Scroll to the rightmost column → click into the empty column labeled '''Add Column'''. | ||
# Type | # Type: | ||
=[ | =[Quantity] * 0.1 | ||
# Press '''Enter'''. | # Press '''Enter'''. | ||
# | # Rename the column to `EstimatedCommission`. | ||
== Navigation == | |||
→ Continue to [[Power Query – Summary and Exercises|Module 6: Summary and Final Exercises]] | → Continue to [[Power Query – Summary and Exercises|Module 6: Summary and Final Exercises]] |
Revision as of 13:22, 22 June 2025
Module 5: Power Pivot Overview
Objective
Learn how to load multiple related tables into the Data Model using Power Query, create relationships in Power Pivot, and build PivotTables using DAX calculations.
Files Used
Enabling Power Pivot Add-in
Steps:
- Open Excel.
- Go to the File tab → click Options.
- In the Excel Options window → select Add-ins.
- At the bottom, next to Manage, select COM Add-ins from the dropdown → click Go....
- In the list, check Microsoft Power Pivot for Excel → click OK.
- The Power Pivot tab will now appear in the ribbon.
Importing Data via Power Query into the Data Model
Steps:
- Go to the Data tab → click Get Data → From File → From Workbook.
- Select and open PowerPivot_Customers.xlsx.
- In Navigator → check the sheet → click Transform Data.
- In Power Query Editor → click the Home tab → click the dropdown under Close & Load → choose Close & Load To....
- In Import Data dialog:
- Select Only Create Connection
- Check the box Add this data to the Data Model
- Click OK
- Repeat these steps for PowerPivot_Products.xlsx and PowerPivot_Sales.xlsx.
Opening the Power Pivot Window
Steps:
- Go to the Excel ribbon → click on the Power Pivot tab.
- Click Manage.
- The Power Pivot window will open showing the loaded tables.
Creating Relationships Between Tables
Steps:
- In the Power Pivot window → click the Diagram View button in the top-right.
- Drag from CustomerID in the Sales table to CustomerID in the Customers table.
- Drag from ProductID in the Sales table to ProductID in the Products table.
- You should now see the relationships as arrows between the tables.
Creating a DAX Measure
Steps:
- In the Power Pivot window → click on the Sales table.
- Scroll to the bottom of the table.
- In the empty cell under the data → type the formula:
Total Sales := SUM([Total])
- Press Enter.
- The measure is now available in PivotTables.
Building a PivotTable from the Data Model
Steps:
- In Excel → go to the Insert tab → click PivotTable.
- In Create PivotTable dialog:
- Select Use this workbook’s Data Model
- Choose location (New worksheet or Existing worksheet)
- Click OK
- Use fields from all related tables:
- Add `Region` from Customers to Rows
- Add `Category` from Products to Columns
- Add `Total Sales` to Values
Additional Exercise: Analyze by Region and Product
Goal: Analyze total sales by region and product category.
Steps:
- Create a PivotTable based on the Data Model.
- Add `Region` (Customers) to Rows.
- Add `Category` (Products) to Columns.
- Add `Total Sales` measure to Values.
- Optional: Apply formatting or sort highest to lowest.
Extension: Add a Calculated Column in Power Pivot
Steps:
- In the Power Pivot window → select the Sales table.
- Scroll to the rightmost column → click into the empty column labeled Add Column.
- Type:
=[Quantity] * 0.1
- Press Enter.
- Rename the column to `EstimatedCommission`.
→ Continue to Module 6: Summary and Final Exercises
Return to Main Page