0% found this document useful (0 votes)
3 views35 pages

Introduction to Power Query Week 2

Power Query is a Microsoft tool for Excel and Power BI that simplifies data connectivity and preparation, enabling users to automate data cleaning tasks without needing programming skills. The Power Query Editor allows users to connect, transform, and load data through a graphical interface, facilitating various data manipulations for effective analysis. Key features include data transformation, filtering, merging, and the ability to create custom columns, making it essential for preparing data for reporting in Power BI.

Uploaded by

hijjiariff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views35 pages

Introduction to Power Query Week 2

Power Query is a Microsoft tool for Excel and Power BI that simplifies data connectivity and preparation, enabling users to automate data cleaning tasks without needing programming skills. The Power Query Editor allows users to connect, transform, and load data through a graphical interface, facilitating various data manipulations for effective analysis. Key features include data transformation, filtering, merging, and the ability to create custom columns, making it essential for preparing data for reporting in Power BI.

Uploaded by

hijjiariff
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Introduction to Power Query

Power Query —Where is Power Query

Power Query is a tool built by Microsoft


for Excel and Power BI.

Power Query is Microsoft’s Data


Connectivity and Data Preparation
technology. It basically, enables business
users to access data stored in data
sources seamlessly whilst, reshaping it to
fit their needs. It’s easy to use, engaging,
even convenient to use for the no-code
users

Power BI utilizes M language


Power Query —Purpose

Automation
There Automate the laborious getting and cleaning data tasks.

No Code | Low Code


Eliminate the need to be a programmer: traditionally if you wanted to
automate these laborious tasks, you’d use Excel’s programming language,
VBA. However, Power Query doesn’t require programming knowledge as
most of its tools are available from the GUI with point and click ease.

Time Saving
Reduce time-consuming tasks that can take hours, down to a fraction of the
time, sometimes as little as a few seconds.
Query Editor

In Power BI, a query editor is part of the Power Query feature. Power Query is used to connect, transform,
and load data into Power BI. The query editor in Power BI allows users to shape and transform data before it
gets loaded into the Power BI model. Users can perform various data manipulations, such as filtering,
merging, and cleaning, using a graphical interface. It's a crucial component for preparing and refining data for
analysis in Power BI reports and dashboards.
Power BI —How to Access Power Query Editor

On the Home ribbon tab, click


Transform data, and it will take you to
the Power Query Editor, also known as
Query Editor

With no data connections, Power


Query Editor appears as a blank pane,
ready for data.
Power BI —Query Editor
1
1. In the Ribbon, many buttons are
now active to interact with the
data in the query.
2
2. In the left pane, Queries Pane,
4 queries are listed and available for
selection, viewing, and shaping.
3
3. In the Data Pane, data from the
selected query is displayed and
available for shaping.

4. The Query Settings Pane appears,


listing the query's properties and
applied steps.
Power BI —Ribbon

1 1. In the Home tab, you may find most


common features used for ETL (get
data). Some of features in home tab are
those of tabs in the ribbon as well.

2 2. In the Transform Tab, there are options


for transformation tasks such as
transform columns, change data types
and other data-driven task

3 3. Add Column tab provides more tasks


associated with adding a column,
formatting column data, and adding
custom columns.
4
4. The View tab on the ribbon is used to
toggle whether certain panes or
windows are displayed. It's also used to
display the Advanced Editor.
Data Transformation

Data transformation is the process of preparing raw data for analysis. In Power BI, it involves cleaning,
sorting, aggregating, merging, and formatting data using the Power Query Editor. This ensures data accuracy
and consistency for effective analysis and reporting.
Power BI —C ommon Data Task for Power Query

• Remove Blanks rows and columns (and other unnecessary data).


• Defining meaningful Table and Column Names.
• Select relevant Data Types.
• Handling Dates in numbers, text, or wrong format.
• Handling Null Values.
• Dealing with Indentation and Line Breaks.
• Add or Remove Delimiters.
• Split and Merge Columns
• Pivot or Unpivot Data.
• Merge(Join) or Append(Union).
• Custom(Conditional) Columns.

https://learn.microsoft.com/en-us/power-bi/transform-model/
Power BI —Data Types

1 2

1. In Power Query Editor, select the


column and then select Data Type in
the Transform tab of the ribbon.

2. Another way is to right click on column


header, navigate to Change Type,
select Data Type

*(For more detail of each data type, refer to the link below)

https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-data-types
Power BI —Basic Row Transformations
Power BI —Basic C olumn Transformations
Power BI —Basic Built-in Transformation Functions
Power BI —Add C olumns
Power BI —Filter Data

1 1. Right click on the arrow, you can select the


values to filter them.
2. Another way to filter is, navigate to Text
Filters where you will find several options to
apply filter to you data.
2 2 *(with Advanced, we can apply more than one condition
for filter)

1
Power BI —Transforming Text (Replace Values)

1. Right click on column name, navigate to Transform, it will


show basic transformation you can apply to clean your data.
2. We can also replace values and errors(default values)

*(To replace null values, in Replace Value → Value To Find, type “null”)

1
2
Power BI —Transforming Text (Split C olumn)

1. Right click on column name, navigate to Split


Column, it will show option by which we can split
columns.
2. Choosing By Delimiter we can define the
conditions and delimiter by which we want to split.
3. In the Advance options, we can select if we want
to create new columns after split or append the
split data
Power BI —Transforming Text (Merge C olumn)

1 1. Select all the columns which you


want to merge by holding ctrl and
selecting them.

2. Right click on any of the column


name, select Merge Columns.
2
3. Select the Separator and Name of
merged column

3
Power BI —Transforming Text (Extract)

1. Select Column, navigate to Add Column,


Click Extract.
2. We have several options to extract text.
For this instance to want to get Year from
Date of Birth, so we choose Last
Characters and type 4 to get the last 4
values.
Power BI —Append Queries (Union)

1. Click Append Queries, select the table


you want to append

2. If have more than two tables to append,


you may select Three or more tables
Power BI —Merge Queries (Join)
1

1. Click Merge Queries, select the table you


want to append
2. Select the columns by which you want to
create Join
3. Select Join Kind

*Check at the bottom if the columns which you selected have


matching values or not
2

3
Power BI —Pivot |Unpivot |Transpose

1. Pivot carries out an aggregation and merges possible multiple rows


into a single row in the output.

2. Unpivot produces the opposite result than what we just experienced


with Pivot. Unpivot will convert you column name into one column
(Attribute) and your values into another column(Value).

3. When apply Transpose, the row become column and vice versa

*(Unlike pivot and unpivot, transpose doesn’t recognize unique values, instead
entire table is transformed so that each row becomes a column and vice versa)
Power BI —Pivot |Unpivot |Transpose
Power BI —Pivot |Unpivot |Transpose
Power BI —Pivot |Unpivot |Transpose

1. Select all the columns which you want to Unpivot column means to unpack the similar values and group them
pivot under a single heading.
2. Right click on any of the column name, When we look at our unsorted data, we see that all the 5 columns show
the same metric(Sales). Therefore we want to separate it into two
select Unpivot Columns. It will result in columns where one column will show City and the other Sale.
two columns, Attribute and Value.

2
Power BI —Pivot |Unpivot |Transpose

1 1. Select the column you want to pivot, navigate to


Transform, click Pivot Column
2. Select the Values Column
3. In Advance options select Aggregation Value
Function

3
Power BI —Pivot |Unpivot |Transpose

1. Select all the columns which you want to fill Fill is required sometimes, especially when getting data from excel and we a un-
structed table. Then we can apply pivot or un-pivot transformations on it, which
without fill wont work.
2. Navigate to Transform and select Fill, then Down *(If the are empty spaces in the columns, we first have to replace them with null,
since fill only nulls, “ ” blank space is still consider a value in text)

1
Power BI —C onditional C olumn

1. Click Conditional Column in Add Column tab.

2. With if else conditions, defined the output we for our new column.
Power BI —Custom C olumn

1. In the Add Column tab, select Custom Column.

2. We may create different calculations, and use


other power query functions to define this
custom columns. For this one, we have simple
divide the sales with the number of units sold.
Power BI —C olumn from Example
1. Click Column From Examples in Add Column tab.
2. Type in few outputs you want from the column, and
Power BI will generate a code itself to create a new
custom column.

This is the code generated by power


BI itself, some the example of outputs
we have provided to it

The greyed out in


the output we will
get if we click ok.
Power BI —Group By

1. Select the column(s) by which you want


to group by.
2. In the Home tab , select Group By.
3. Select the aggregation type and its
corresponding data column.

*(if you select Advanced, you can add aggregation on


multiple columns and add the more columns for group by)
Queries Pane Option

The Queries pane in Power BI's Power Query Editor displays applied data transformation steps, allowing
users to view, reorder, and modify these steps. It provides insights into the sequence of actions applied to
shape and clean the data.
Power BI —Query Pane O ptions

Right click on a query will open up this menu.

1. If you check Enable load, the table will be loaded on Power BI


desktop Data view. If it is unchecked, it will be not be loaded.

1 2. Unchecking Include in report refresh means the data will not


2 be updated even when the refresh has been applied on the
3 whole report.
4
3. Duplicate creates an exact copy of the query and will have no
relation with the original query

4. Reference creates a copy of a query same as duplicate,


however, the source of this query will be the original query
and any changes in the original query will affect the reference
query(hence reference in name). It is to be noted, any changes in
reference query wont affect the original query.
Power BI —Grouping Q ueries

1. Select Queries you want to group.


2. Right click, navigate to Move to
1
Group, select New Group
3. Give name to the group

*(It is only meant for organizing the queries and


2 wont have any effect on ETL process)

3
Power BI —Advance Editor

Power Query Advance Editor show the


M code which Power BI wrote for the
Applied Steps we performed for our ETL

You might also like