Locked lesson.
About this lesson
When building models, many users pull in data that is far too granular, resulting a many more records than they need. Power Query offers a tool to group that data for you, so that you aren't wasting storage space on unnecessary records.
Exercise files
Download this lesson’s related exercise files. You can download source data files for the course from the resources section of your Lessons page.
Grouping Data.xlsx19.4 KB Grouping Data - Completed.xlsx
25.8 KB
Quick reference
Grouping Data
Grouping data allows aggregating tables of data to get to a summarized level.
When to use
Use when you have an excess of detailed data and only need the summarized version for your analysis.
Instructions
Getting started
- Create a new query to bring your data to Power Query
- Go to the Transform tab --> Group By --> Advanced
Adding/modifying grouping levels
- Choose the field to group by from the “Group By” drop-down
- To add new grouping levels click Add Grouping
- Mouse over the right side of the drop-down and click the ellipses (…) to
- Change the grouping order
- Delete a grouping level
Adding/modifying aggregation columns
- In the bottom half of the Group By dialog
- Enter the name you wish for your aggregated column
- Choose the type of aggregation for your column
- Choose the column you wish to aggregate
- Add new aggregation levels by clicking Add Aggregation
- Mouse over the right side of the aggregation and click the ellipses (…) to
- Change the grouping order
- Delete a grouping level
Hints & tips
- Changing a grouping operation will not update the new column name for you
- You can set as many grouping levels or aggregations as you like
- There is no need to remove columns you do not wish to preserve before applying grouping as only the grouped columns will remain after grouping your data
- Aggregation operations include
- Calculating the Sum, Average, Median, Min or Max of the column
- Counting the rows or Distinct rows of data in the grouped column
- Preserving All Rows that made up the grouped data (for later expansion)
Lesson notes are only available for subscribers.