Adding an aggregation
Adding an aggregation
Overview
In the exercise Creating an aggregation, you were asked to create and manage an aggregation
in Power Query editor to reduce the data size of the Fact table and optimize query
performance.
Create an aggregation based on the Fact table (Sales table) according to the required
granularity.
Configuring the data types of the aggregated columns and the source columns.
Manage the aggregation in Power BI desktop.
This reading provides you with a step-by-step guide for completing these tasks. It also includes
screenshots that you can compare against your work.
You can also review the Creating an aggregation and Managing aggregations videos.
1. In the Rename field, rename the new table to SalesAgg. Duplications save the
original tables for other analytics needs. So always copy the source table and create an
aggregate from the duplicate copy.
1. Choose the columns that you want to keep in the aggregated table from the source table
by selecting the Choose column option on the Home tab in the Power Query
editor window.
1. In the Choose column window select the following columns:
OrderDate (This column is added to group data and will be used for the group by step)
Total Sales
Quantity
Cost
1. Next, select the Transform tab in the Power Query editor window and then Group
by. This opens the Group by window, where you can define aggregate columns and
mathematical operations to compute the aggregation.
1. Group the aggregation by the OrderDate field in the Group by window.
1. Create the following aggregate columns in the Group by window:
1. Open the Power Query editor again to ensure that the data types of the aggregate
columns match the data types of the source columns as follows using the Data type icon
to the left of each column:
The data type of the column using Count must be set to Whole number.
The data type of SumTotalSales and SumCost must be Fixed decimal
number.
You can change the data type by selecting the Data type icon on the left side of the column
name in the Power Query editor. Once you have completed the data type configuration, select
Close and apply to return to Power BI desktop interface.
Step 4: Save the Power BI project.
Save the Power BI project to your local computer.
To save the project, open the File menu, select Save As, and provide an appropriate name for
the project along with a path to the folder on your computer.
Conclusion
With these steps, you have successfully created and configured an aggregation within the data
model of Microsoft Power BI to reduce the data size significantly. You are now in the situation to
help Adventure Works optimize the query performance and enhance user experience while
interacting with the reports and visualizations.