Skip to main content

How to aggregate data in Power BI

Aggregating data means that you summarize data and present it at a higher level. For example, summarizing sales data and grouping it by date, product, or customer. The benefit of aggregating your data is that it reduces the table sizes in the data model, improves query performance, and allows users to focus on the important aspects of the data. 


Reasons for using aggregations in your data models:

  • When working with a large amount of data (big data), aggregations will provide increased query performance, facilitate analysis, and insights from this large data. Aggregated data uses a fraction of the resources compared to more detailed data.
  • If experiencing a slow refresh, aggregations will help to speed up the refresh process. The smaller cache size reduces the refresh time and enhances the user experience. Instead of refreshing millions of rows, you can reduce the number of rows significantly by using data aggregation.
  • When you are working with a large data model, aggregations can be helpful to reduce and maintain the size of your model. Also if you anticipate that the amount of data will grow in the future. It can be smart to use aggregations proactively in order to future-proof the solution. 


Before creating aggregations, you should decide on the level at which you want to analyze the data. In this example, you want to aggregate the sales data on a weekly basis. When you have decided on the level, the next step is to choose how you want to create the aggregations. It is possible to create aggregations in different ways and each method will yield the same results.

  • Directly in the database, you could create a table with the aggregation and thereafter import that table into Power BI Desktop.
  • Directly in the database, you could create a view for the aggregation and then import that view into Power BI Desktop.
  • In Power BI Desktop by using Power Query to create the aggregations step-by-step.


In the example below, we will use Power Query to perform the weekly aggregation. Notice that before the aggregation our table has more than 999 rows. 


We want to aggregate the data by the week_nb column and view the actual_sales_pcs column. Start by selecting Choose Columns on the Home tab. On the window that displays, select the columns that you want in the aggregation and then select OK.

Select the Group By option on the Home tab. On the window that displays, first select the column that you want to group by (week_nb), enter the name for the new column (Weekly Sales), choose Operation (Sum), and which column to summarize (actual_sales_pcs).

The data is now transformed and aggregated for each week, and you will be able to see the summarized sales quantity. Remember, that we started with over 999 rows. By aggregating the data we have significantly reduced the number of rows in the dataset from over 999 to 51 rows. This means that Power BI has less data to refresh and therefore should perform better. 



Comments

Popular posts from this blog

AI School: How to Use Chat GPT

Chat GPT changed the conversation about artificial intelligence - the technology that is predicted to revolutionize how businesses and individuals interact with computers. Despite its impressive potential, the service is far from user-friendly in all aspects. In a series of articles, Techsavvyminds tests and guides you, the reader, through the basics of the most talked-about AI services. First up is Chat GPT from the American company Open AI. Over half a year has passed since Chat GPT transformed the conversation about artificial intelligence. For companies, it has been said that AI can streamline everyday tasks by taking over repetitive tasks, assisting with presentation materials, and even handling email conversations. Although the hype has been hard to miss, it hasn't been obvious to everyone to explore the possibilities of this new technology. Others have tried and realized that the shortcomings are still too significant to make a real difference in everyday life. The only way ...

5 Proven Strategies to Pass the Microsoft Power BI Data Analyst - PL-300 Exam

Earning a certification in Power BI as a data analyst is a great way to validate your skills, enhance your career prospects, improve your skills, enhance your credibility, and demonstrate your commitment to professional development. To excel in this exam, candidates must have a strong grasp of Power Query and proficiency in writing Data Analysis Expressions (DAX). They should also possess knowledge in assessing data quality and be familiar with data security measures such as row-level security and data sensitivity.  The following skills are evaluated:  Prepare the data (25–30%) Model the data (25–30%) Visualize and analyze the data (25–30%) Deploy and maintain assets (15–20%) The Microsoft PL-300 exam is designed for candidates who want to validate their skills as Data Analysts. Here are some tips to help you prepare for and pass the PL-300 exam: 1. Review the exam objectives:  The first step in preparing for any exam is to review the exam objectives. These objectives pro...

SQL 101: Analyzing Data with functions COUNT, SUM, AVG, and MAX

SQL is a powerful language for managing and analyzing data stored in relational databases. When it comes to manipulating data, SQL offers a number of built-in functions that allow you to perform calculations on your data. In this article, we'll take a closer look at four of these functions - COUNT, SUM, AVG, and MAX - and show you how you can use them to perform common calculations and analysis tasks. Let's start with the COUNT function. This function is used to count the number of rows in a table or a specific column of a table. The syntax for the COUNT function is straightforward: SELECT COUNT(column_name) FROM table_name; You can also use the COUNT function to count all rows in a table, regardless of the presence of null values, by using the wildcard character *: SELECT COUNT(*) FROM table_name; For example, if you have a table of employees and you want to count the number of employees in the company, you could use the following SQL query: SELECT COUNT(*) FROM employees; The...