You are on page 1of 24

Data Visualization With Power BI

Lesson 2&3 : Power Query

Dileepa Samayawardena, Power BI


Power Query Power BI

Discover Connect Combined Refine

Raw Level Data Transform Analysis

Dileepa Samayawardena, Power BI


M Language Power BI

Functions Variable Expression Values

Dileepa Samayawardena, Power BI


Power BI

Power BI Main Window : Canvas Edit Query Option

Dileepa Samayawardena, Power BI


Load the Data M Power BI
language
can be
Get Data From used
Multiple Data
Sources

Handel Errors
in the
Data Set

Dileepa Samayawardena, Power BI


Components in Edit Query Power BI

1. In the ribbon, many buttons are now active to


interact with the data in the query.

2. In the left pane, queries are listed and available


for selection, viewing, and shaping.

3. In the center 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.

Dileepa Samayawardena, Power BI


Power BI

Each Query in Power BI


Desktop is a Single Power
Query Let Expression

Dileepa Samayawardena, Power BI


Power BI
Demo

let Dataset = Csv.Document(File.Contents("C:\ChurnData.csv"),


[Delimiter=",",Encoding=1252])
in Dataset

Dileepa Samayawardena, Power BI


Power Query : Options Intro Power BI

Data Type Introduction

Applied Steps Section

Main Tabs Introduction

Data Refresh Options

Dileepa Samayawardena, Power BI


Power BI

Column
Transformation

Dileepa Samayawardena, Power BI


Unpivot Option Power BI

Situation: You get multiple columns table. You need to change this into tables
having separate Columns for Name and Value. The Unpivot Columns feature turns
multiple column headers into a single column but in rows. The values get stored
under the original columns in another column

Dileepa Samayawardena, Power BI


Limitation In Lookup Function Power BI

• Only one lookup column can be used


• Can get values from one column
• Values only from the columns on right side
• Consume the memory and slow down the
calculations
• No cross lookup from the both tables

Merge Option : Comparison with Lookup

• Merge two queries


• Can consider more than one column
• Get even multiple rows from the tables
• Get all/ selected columns in other table
• Work on both table on same time
• Fast in comparison
Dileepa Samayawardena, Power BI
Two Tables

Left Table Right Table

Only two rows are matching


Other rows do not match

Dileepa Samayawardena, Power BI


Full Outer Join

All rows from both tables will be selected


In combined table, we have all the rows from both table
All the rows from left table come first, then matching rows from right table come and non matching
rows in right table come with null values Dileepa Samayawardena, Power BI
Full Inner Join

Opposite of the full outer, Only matching


Only overlapping area has been colored
All the matching rows from left table come first, then matching rows from right table come
Dileepa Samayawardena, Power BI
Right Outer Join

Only interested in right table rows and the matching rows from the left table
All the rows from right table will be appeared and only matching rows from the left table will be
matched to those rows from right table
Non matching rows from left table will beDileepa
ignored
Samayawardena, Power BI
Right Outer Join :Anti

Now you want only the non matching rows of the right table with the left table
Where we will get “Errors” because of non matching scenarios

Dileepa Samayawardena, Power BI


Left Outer Join

Only interested in left table rows and the matching rows from the right table
All the rows from left table will be appeared and only matching rows from the right table will be
matched to those rows from left table
Non matching rows from right table will be ignored
Dileepa Samayawardena, Power BI
Left Outer Join : Anti

Now you want only the non matching rows of the left table with the right table
Where we will get “Errors” because of non matching scenarios

Dileepa Samayawardena, Power BI


Power BI

Row
Transformation

Dileepa Samayawardena, Power BI


Power BI

Built in
Transformation
Function

Dileepa Samayawardena, Power BI


Append & Combined Options

Similar data structure and similar data type in all the queries

Dileepa Samayawardena, Power BI


Power BI

Built in
Transformation
Function

Dileepa Samayawardena, Power BI


Thank You !!

Dileepa Samayawardena, Power BI

You might also like