Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 19

Power BI

What is power BI????


Power BI is a business analytics service by Microsoft that aims to provide interactive visualizations and
business intelligence capabilities with an easy-to-use interface for end users. It allows users to connect
to various data sources, import data, transform and clean it, and create visually appealing reports and
dashboards. Power BI enables organizations to make data-driven decisions by analyzing large datasets
and uncovering insights through data visualization, collaboration features, and integration with other
Microsoft products like Excel

Now to download power BI just type download power bi in google

Go to the first link and you have to download Microsoft power bi desktop.

After clicking on the advance download just download 64 bit variant.


After downloading and installing software you have Power BI desktop installed in your machine.

Open power BI desktop from your desktop.


At starting you will see screen like this.
After click you will see

Now let’s talk about Power BI

Power Bi desktop is divided into 2 parts

1. Power bi desktop > used to create visuals


2. Power query editor> used to manipulate data

Now power query editor also called as an ETL tool.

Question arises what is ETL tool.

ETL full form is EXTRACT TRANSFORM LOAD.

EXTRACT means to extract the data from different sources these sources could be excel, server, csv etc.

TRANSFORM means to transform the data; we know that our data never come in a clean and processed
way we have to clean and preprocess the data in such way that we can use it inside visualization.

LOAD mean now our data is ready and we can create some visualization now its time to load the data
into the Power BI.

Now our first step is to extract data!!

From where we have to extract data? let’s first take an example of excel file
TO extract data, we click on get data after click we can see some
common data source

These are some common data sources we find on Get data tab
through which we can connect our data source to power BI.

Now let’s click on more data to show more data sources

These sources are called connectors in power BI. There are more than 200 connectors in power BI.

Before connecting it to an excel file let us first download an excel file called sample superstore from
google.

https://www.kaggle.com/datasets/bravehart101/sample-supermarket-dataset download it from here.

Now click on excel workbook connector and select your sample superstore file.
A navigator page will open and you have to select your excel sheets as table in our power bi. Orders,
People and Returns.

Below you will see 2 options Load and Transform Data

If we click on load our data will simply load into power bi desktop but if we click on transform data our
data will go into power query editor.

Now first click on transform data.


Here you can see a new window will open this window is called power query editor in power query
editor we can transform our data.

As we can see our data is inside our power query editor

Now here we can manipulate our data.

All the steps and functionality of tools are briefly covered in videos.

Important question related to power query editor.

Q1: what is power query editor, and why we use it?

Ans: Power Query Editor is an ETL tool in Power BI that helps you clean, transform, and shape your data
before loading it into your Power BI reports. It allows you to easily manipulate and prepare your data for
analysis by performing various operations such as filtering, sorting, merging, and creating custom
calculations. In simple terms, it helps you get your data ready for analysis quickly and efficiently.

Q2: How to import the data into power bi?

Ans: To import data into Power BI:

1. Open Power BI Desktop.

2. Click on the "Home" tab.


3. Select the type of data source you want to import from, such as Excel, CSV, SQL Server, or other
options available under the "Get Data" section.

4. Choose the specific file or database table you want to import from.

5. If required, enter any necessary credentials to access the data source.

6. Select any specific data transformation or filtering options you need.

7. Click "Load" or "Transform Data" to import the data into Power BI.

Q3: What happened if I change the location of my data source file, will power query editor still works for
me?

Ans: No. When you try to refresh the data in Power BI, it will encounter an error because it cannot find
the original file at the specified location.

To address this issue, you can follow these steps:

If you import an Excel file into Power BI and later change the location of the Excel file, Power Query
Editor will not automatically update to reflect the new file location. When you try to refresh the data in
Power BI, it will encounter an error because it cannot find the original file at the specified location.

To address this issue, you can follow these steps:

1. Open the Power Query Editor: Go to the Home tab in Power BI Desktop and select "Transform
Data" to open the Power Query Editor.

2. Update the Data Source: In the Power Query Editor, locate the data source that points to the
Excel file. It will likely be listed in the "Queries" pane on the left.

3. Edit the Data Source: Right-click on the data source and select "Advanced Editor" or "Edit
Settings" to open the data source settings.

4. Update the File Path: In the data source settings, update the file path to reflect the new location
of the Excel file. You can either enter the new file path manually or use the file picker to navigate
to the new location.
5. Apply Changes: Once you've updated the file path, apply the changes to update the data source
in Power Query Editor.

6. Refresh Data: After updating the data source, you can refresh the data in Power BI to load the
updated data from the new file location.

By following these steps, you can ensure that Power Query Editor continues to work even if you change
the location of your data source file.

Q4: How do you access Power Query Editor in Power BI Desktop?

Ans: Accessing Power Query Editor in Power BI Desktop is straightforward. Here's how you can do it:

1. Open Power BI Desktop.

2. After opening Power BI Desktop, you will typically see the Home tab selected by default.

3. Look for the "Home" tab in the ribbon menu at the top of the screen.

4. Within the Home tab, locate the "Transform Data" button. It's represented by an icon that
resembles a table with a pencil on top.

5. Click on the "Transform Data" button.

Once you click on "Transform Data," Power Query Editor will open, allowing you to perform various data
transformation tasks on your dataset before loading it into Power BI.

Q5: How do you remove duplicate rows from a dataset using Power Query Editor?

Ans: To remove duplicate rows from a dataset using Power Query Editor in Power BI Desktop, you can
follow these steps:

1. Open Power Query Editor: Access Power Query Editor by clicking on the "Transform Data"
button in the Home tab of Power BI Desktop.

2. Select the Table: In Power Query Editor, select the table or query from which you want to
remove duplicate rows. The data will be displayed in the main window.

3. Remove Duplicates:

 Click on the column header of the column(s) you want to check for duplicates.

 Go to the "Home" tab in the ribbon menu.

 Find and click on the "Remove Rows" dropdown menu.

 Select "Remove Duplicates" from the dropdown menu.

4. Confirm Removal: A dialog box will appear showing the columns that will be used to identify
duplicate rows. You can select or deselect columns as needed.
 Click "OK" to remove the duplicate rows based on the selected columns.

5. Close and Apply: Once you've removed the duplicate rows, click on the "Close & Apply" button
in the Home tab to apply the changes and close Power Query Editor.

By following these steps, you can easily remove duplicate rows from your dataset using Power Query
Editor in Power BI Desktop.

Q6: What is difference between merge and append query?

Ans: The difference between merging and appending queries in Power Query Editor lies in how they
combine data from multiple tables:

1. Merge Queries:

 Merging queries combines data horizontally based on matching values in one or more
columns.

 It creates a new table that includes columns from both tables, where rows are matched
based on the specified criteria.

 Merging is typically used when you want to combine data from multiple tables based on
common values in specific columns, similar to a SQL join operation.

 Merging can result in a wider table with additional columns from the merged tables.

2. Append Queries:

 Appending queries combines data vertically, stacking one table below another.

 It creates a new table that contains all the rows from the first table followed by all the
rows from the second table.

 Appending is typically used when you want to combine data from multiple tables with
the same structure (same columns), such as when you have multiple datasets with the
same schema.

 Appending increases the number of rows in the resulting table while keeping the same
set of columns.

In summary, merging is used to combine data horizontally based on matching values in columns, while
appending is used to combine data vertically, stacking tables on top of each other. The choice between
merging and appending depends on how you want to combine the data and the structure of the tables
involved.
Q7: How do you merge or append multiple tables in Power Query Editor?

Ans: To merge or append multiple tables in Power Query Editor, follow these steps:

1. Open Power Query Editor: Access Power Query Editor by clicking on the "Transform Data"
button in the Home tab of Power BI Desktop.

2. Load the Tables: Ensure that all tables you want to merge or append are loaded into Power
Query Editor. You can do this by either importing multiple tables from different data sources or
by duplicating existing tables.

3. Merge Tables:

 To merge tables based on matching values in one or more columns, select one of the
tables.

 Go to the "Home" tab in the ribbon menu.

 Click on the "Merge Queries" dropdown menu and select "Merge Queries."

 Choose the second table you want to merge with and select the common column(s) to
use for the merge.

 Choose the type of join (e.g., Inner, Left Outer, Right Outer, Full Outer) and click "OK."

 The merged table will be created with combined columns from both tables.

4. Append Tables:

 To append tables vertically (stacking one table below another), ensure that the tables
have the same columns.

 Select one of the tables.

 Go to the "Home" tab in the ribbon menu.

 Click on the "Append Queries" dropdown menu and select "Append Queries."

 Choose the table you want to append and click "OK."

 The tables will be appended one below the other, creating a single table with combined
rows.

5. Close and Apply: Once you've merged or appended the tables as needed, click on the "Close &
Apply" button in the Home tab to apply the changes and close Power Query Editor.

By following these steps, you can merge or append multiple tables in Power Query Editor to combine
data from different sources or tables within Power BI Desktop.
Q8: Different types of joins in merge table?

Ans: In Power Query Editor, when you merge tables, you have several options for the type of join to
perform. Here are the different types of joins available:

1. Inner Join:

 Retains only the rows where there is a match in both tables based on the specified join
columns.

 Rows with no matching values in the other table are excluded from the result.

2. Left Outer Join:

 Retains all rows from the left (first) table, and includes matching rows from the right
(second) table.

 If there is no match in the right table, null values are included for columns from the right
table.

3. Right Outer Join:

 Retains all rows from the right (second) table, and includes matching rows from the left
(first) table.

 If there is no match in the left table, null values are included for columns from the left
table.

4. Full Outer Join:

 Retains all rows from both tables, regardless of whether there is a match in the other
table.

 For rows with no match in the other table, null values are included for columns from the
non-matching table.

5. Left Anti Join:

 Retains only the rows from the left (first) table where there is no match in the right
(second) table.

 Excludes rows where there is a match in the right table.

6. Right Anti Join:

 Retains only the rows from the right (second) table where there is no match in the left
(first) table.

 Excludes rows where there is a match in the left table.

These different types of joins give you flexibility in how you combine data from multiple tables based on
your specific requirements and the relationships between the datasets.
Q9: What is difference between duplicate and reference?

Ans: In Power Query Editor, "Duplicate" and "Reference" are two distinct operations used to manipulate
data, though they may seem similar at first glance. Here's the difference between them:

1. Duplicate:

 When you duplicate a query or a table in Power Query Editor, you create an exact copy
of the original data.

 Any changes made to the duplicated query or table will not affect the original data.

 Duplicating is useful when you want to preserve the original data for comparison or for
performing different transformations without altering the source data.

2. Reference:

 When you reference a query or a table in Power Query Editor, you create a new query
that points to the original data.

 Any changes made to the original data will be reflected in the referenced query.

 Referencing is useful when you want to reuse the transformations applied to the original
data in multiple places within your Power BI project.

 It helps maintain consistency and ensures that updates to the original data are
automatically propagated to all referenced queries.

In summary, duplicating creates a standalone copy of the data, while referencing creates a link to the
original data, allowing for dynamic updates. The choice between duplicating and referencing depends on
whether you need independent copies of the data or want to maintain a connection to the original
source.

Q10: What is the use of query properties in power query editor?

Ans: The options "Enable load to report" and "Include in report refresh" in Power Query Editor serve
different purposes:

1. Enable Load to Report:

 This option determines whether the data retrieved and transformed by the query will be
loaded into the Power BI report.

 When enabled, the query's data will be available for use in visualizations, calculations,
and other parts of your report.

 Disabling this option keeps the query's data in the Power Query Editor only and prevents
it from being loaded into the report.
2. Include in Report Refresh:

 This option specifies whether the query should be included in the data refresh process
when the report is refreshed.

 Enabling this option ensures that the query's data is refreshed along with other data
sources in the report when the report is refreshed.

 If disabled, the query's data will not be refreshed automatically when the report is
refreshed. However, you can still refresh the query manually in Power Query Editor.

In summary, "Enable load to report" determines whether the query's data is loaded into the report,
while "Include in report refresh" determines whether the query is included in the data refresh process
when the report is refreshed. Depending on your requirements, you can adjust these options accordingly
to control the behavior of your queries in Power BI reports.

Now let’s start Power BI Desktop

We will study DAX (data analytics expression) Dax is a library which contains set of functions to
manipulate or create data in power bi.

In dax we create 3 kinds of things

1. Columns
2. Measure
3. Table

Now what is the difference between columns measure and table dax

Columns or calculated columns help to create a new column in our table. Normally we can see this
column inside our table so it takes some space in our data and consume some memory

Measure or calculated measure summarize our data into a single value eg like sum of sales is a single
value since it stores only single aggregated value it takes less space.

Table Dax is used to create a new table.

Operator used in some Dax functions.

1.Arithmetic operators: +, -, *, /

2. Comparison operators: =, >, <, >=, <=, <>


3. Concatenation: &

4.Logical: &&, ||, not

First lets study about Column Dax

To create a calculate column click on any column in our table a new column tool window will pop up now
click on new column to create a new column in our table

A functional bar will open where before the = sign we can define the column name and after that we can
define our column dax

When we are creating a new column mostly, we can do some kind of numeric as well as textual changes
in our column.

In this eg I have created a column of total sales which says multiply sales in order table into quantity.
And press enter

A new column is created which multiply these values of sales and quantity for every row.

I this eg we can see that while creating column we can perform some mathematical operations and can
also perform complex arithmetic operations in it.

Now create some text calculated columns

1. Left
2. Right

Let’s create another column again clicking on new column

3. Mid
It extracts text from middle
4. Concatenate
it joins 2 strings or columns value

Now remember concatenate can only join 2 columns at one time what if we want to concatenate
3 columns then what

For that we use (&) sign to join two or more than 2 columns
5. Find

6 Search

Gives same value similar to Find but Find is case sensitive and search is not case sensitive.

7. Replace

You might also like