IntroductionGetting Stared with Power BIData Sources in Power BIData Modelling in Power BIDAX In Power BIPower BI VisualizationPower Bi Service
Data Transformation in Power Query
Power Query is an essential tool for transforming and cleaning data before it’s loaded into Power BI. It allows users to apply a series of transformation steps to shape data into a more useful format for analysis.
Overview of Power Query
- Power Query is a data connection and transformation tool built into Power BI Desktop. It provides an intuitive user interface for performing ETL (Extract, Transform, Load) processes on raw data before it is loaded into Power BI’s data model.
- The Power Query Editor opens when users select “Transform Data” from the Home tab. Here, users can perform various transformations on data, such as removing unwanted columns, changing data types, and creating calculated columns.
ETL Process (Extract, Transform, Load)
- Extract: The first step involves extracting data from various sources, such as databases, files, web services, or cloud platforms.
- Transform: This is the most important step where users can clean and shape the data to fit the report requirements. Transformations include filtering rows, renaming columns, merging tables, pivoting/unpivoting data, etc.
- Load: After transforming the data, it is loaded into Power BI’s data model, where it can be used to create visuals and reports.
Steps in Power Query: Removing Columns, Filtering Data, Merging Queries, Pivot/Unpivot
Removing Columns
- Use Case: Often data sets include irrelevant or unnecessary columns. Removing such columns helps streamline the dataset.
- How to Remove: Right-click on the column header and select Remove or use the Remove Columns button from the Power Query ribbon.
Filtering Data
- Use Case: Sometimes only a subset of the data is required. For instance, you might want to filter out records from a specific region or time period.
- How to Filter: Click the filter icon next to the column header to set filter criteria, such as text contains, greater than, less than, etc.
Merging Queries
- Use Case: In cases where data is spread across multiple tables, merging queries allows you to combine them into a single table.
- How to Merge: Use the Merge Queries option to join two or more tables based on a common field (like a primary key).
Pivot/Unpivot
- Use Case: Pivoting and unpivoting are essential transformations when you need to reshape data.
- Pivoting: Converts data from rows to columns, often used when you need to create summary reports.
- Unpivoting: Converts columns into rows, ideal when you want to normalize data for analysis.
- How to Pivot/Unpivot: Right-click on the columns and select Unpivot Columns or use the Pivot Column button on the Power Query ribbon.
Advanced Editor (M Code)
The Advanced Editor in Power Query is where users can view and edit the M code, which defines the transformation steps performed in Power Query.
- M Code: M is a functional language used to describe the data transformation process. It’s automatically generated by Power Query but can also be manually written or edited for more complex scenarios.
- Use Case: The Advanced Editor is used when more advanced transformations are needed, or when users want to customize the process beyond the capabilities of the visual interface.