0% found this document useful (0 votes)
4 views

Adding an aggregation

This document provides a step-by-step guide for creating and managing an aggregation in Power BI to optimize query performance and reduce data size. It outlines tasks such as creating an aggregated table named SalesAgg, configuring data types, and establishing relationships between tables. The guide includes instructions for downloading necessary files, transforming data, and saving the Power BI project.

Uploaded by

ebadmohdhusain
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Adding an aggregation

This document provides a step-by-step guide for creating and managing an aggregation in Power BI to optimize query performance and reduce data size. It outlines tasks such as creating an aggregated table named SalesAgg, configuring data types, and establishing relationships between tables. The guide includes instructions for downloading necessary files, transforming data, and saving the Power BI project.

Uploaded by

ebadmohdhusain
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 22

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.

Your tasks in the exercise include:

 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.

Step 1: Download the Adventure Works Power BI


project.
1. Download and save the file Adventure Works.pbix. Load the data from the
workbook into Power BI. Select the Preview pane to open a table preview. The data
model has three tables of data: Sales, Products, and Date.
1. Download and save the Excel spreadsheet Adventure Works Data.xlsx.
2. Next, select on File in the top-left corner of the screen. In the dropdown menu, hover
over Options and settings, and then select Data source settings.
1. A new window titled Data source settings will appear. Here, you'll see a list of all
the data sources currently used in your Power BI reports.
2. After selecting the data source, click on Change Source... to modify its details.
Navigate to the file location of the Adventure Works Data spreadsheet.
1. Once you’ve made the necessary changes, select OK to confirm and Power BI will
validate the new connection.
Step 2: Create an aggregated table named
SalesAgg
1. On the Home tab, selectTransform data and then Transform data from the
drop-down menu.
1. In the Power Query editor window, select the Sales table from the Queries pane on
the left and right-click to open the context menu. Select Reference to duplicate the
table. Use right-click again to re-open the menu.

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:

 TotalQuantityCount that uses the Count function as an operation.


 SumTotalSales, which performs a Sum as a mathematical operation and uses
Total Sales as the column reference.
 SumCost also uses the Sum function and Cost as the column reference.
1. Select OK to apply all changes to the aggregation.
1. Select Close and apply on the Home tab to close the Power Query editor and
return to the Microsoft Power BI desktop interface.
1. Select the table from the Data pane to display the total number of rows. In the Sales
table, the number of rows is 57851. The number of rows in the SalesAgg aggregated
table is only 990, which is 1.71% of the original rows, a significant reduction in data size.
Step 3: Establish relationship and manage
aggregation in Power BI.
1. The new aggregated SalesAgg Fact table does not have a relationship with the Date
table. Switch to Model view and establish a relationship between the two tables based
on the OrderDate field.

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.

You might also like