Create Table Using Power Query in Power BI (With 31 Real Examples) - SPGuides
Create Table Using Power Query in Power BI (With 31 Real Examples) - SPGuides
MENU
In this Power BI Tutorial, we will discuss how to create table using Power Query in
Power BI. And also we will discuss the below examples:
https://www.spguides.com/create-table-using-power-query/ 1/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
If you are a beginner in Power BI, check out What is Microsoft Power BI and a video
tutorial on Power BI.
Table of Contents
We will use Enter data option to enter data directly into the Power Query data, then we
can load the data into Power BI.
MY LATEST VIDEOS!
https://www.spguides.com/create-table-using-power-query/ 2/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
In the Power Query editor, click on the Enter data from the ribbon.
Once you click on Enter data option, Create Table window will open.
Here you can enter your own column name and row value based on your
requirement. In this case, I have created three columns i.e. Product name, order
date, and Price
This column.
ad will end in 17
Grammarly Lear
https://www.spguides.com/create-table-using-power-query/ 3/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now you can see the table get created directly inside the Power query editor.
https://www.spguides.com/create-table-using-power-query/ 4/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
This is an example of how to create a table in Power Query in Microsoft Power BI.
The Blank query in the Power query editor gives a space where you can query a new
query, which means you will write the queries from scratch to create a new query or
table.
The syntax is to create columns and add row values using the blank query in the Power
query editor.
#table(
{
"Name", // First Column Name
"Age" // Second Column Name
},
{
{
Alex,28 // First Row Field Values
},
{
Hussain,46 // Second Row Field Values
}
https://www.spguides.com/create-table-using-power-query/ 5/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
}
)
Sider.AI O
We will create a custom table using Blank query in Power Query Editor.
In Power Query Editor, click on the New source-> select Blank Query.
https://www.spguides.com/create-table-using-power-query/ 6/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
In the formula, the first part of the table function is the name of the column, and
the second part is the row value.
Then write the query in the Formula bar, to create the table having two columns
i.e. Name and Department with row value provide the below formula. Press
enter or click on the tick symbol.
Then you can change the data type from the Data type option present in the
ribbon.
= #table({"Name","Department"},{{"Alex","IT"},{"John","Finance"},
{"Ruby","IT"}})
It will create a custom table with two columns in the Power Query table.
This is an example of Power BI how to use a blank query in the Power query editor.
https://www.spguides.com/create-table-using-power-query/ 7/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
So here we will use the below table to add a column from an example by using Power
Query Editor.
We will add a new column by providing more than one sample value to create it. It can
be done by providing the input-based selected column. In this case, the selected
column is Rank Name.
In Power Query Editor, go to Add column-> select Column From Example-> From
selection from the ribbon.
https://www.spguides.com/create-table-using-power-query/ 8/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now rename Column 1 to Rank and provide a value from the selected column. In
this case, it is “1.”, query editor will show the rank i.e., 1., 2., and so on. And the
transformation steps can see in the Data Preview. Then click on OK.
Now you can see in the data table, we have added a rank column.
This is an example of how to use a Power query to add the column in Power BI.
https://www.spguides.com/create-table-using-power-query/ 9/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
So here we have two tables, one is the Emp table having column Name and
Department, and another in Date table having a single column i.e DOB.
Emp table
power bi how to use power query add a column from another table
Date table
https://www.spguides.com/create-table-using-power-query/ 10/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Next, we will add the Name column from the employee table to the Date table. Follow
the steps below:
In Power Query Editor, go to Add column tab-> Custom column from the ribbon.
Then Custom column window will open, in the formula box write the below
formula to add the name column to the data table. Then click on Ok.
#"Emp table"[Name]
https://www.spguides.com/create-table-using-power-query/ 11/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now click on Expand icon in the Name column-> click on Expand to New Row
from the options.
Now you can see the Name column added to the Date table using a custom column in
the Power query editor.
https://www.spguides.com/create-table-using-power-query/ 12/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Microsoft power bi use power query to add a column from another table
This is an example of how to use a power query to add a column from another table in
Power BI.
We will remove the duplicated value from the table or column, using Power Query
Editor in Power BI.
https://www.spguides.com/create-table-using-power-query/ 13/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
In Power Query Editor, go to the Home tab-> Remove rows-> Remove Duplicates
from the ribbon.
Now you can see all the duplicated values are removed from the table.
This is an example of how to use the Power query to remove duplicates in Power BI.
https://www.spguides.com/create-table-using-power-query/ 14/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
For this example, we will use the below table, and then we will add the column for the
Age category. If the age is greater than 18 then Adult, and if less than 18 then children.
https://www.spguides.com/create-table-using-power-query/ 15/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
In Power Query Editor, go to Add column-> Conditional column from the ribbon.
Now Conditional column window will open, Then provide the name to the
column as Category and provides the If part Age is greater than 18, then Adult,
else child.
If you want to add the If clause then clicks on the Add clause icon.
https://www.spguides.com/create-table-using-power-query/ 16/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now you can see the column category based on the Age column.
This is an example of how to use power query add column if statement in Power BI.
So here we have the below table based on the Month number we will get the month
name, i.e. if the Month number is 1 then the value is Jan, 2 then the value is Feb.
https://www.spguides.com/create-table-using-power-query/ 17/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
https://www.spguides.com/create-table-using-power-query/ 18/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
https://www.spguides.com/create-table-using-power-query/ 19/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now you can see the conditional column based on condition is added to the
table using the Power Query editor in Power BI.
This is an example of how to use a power query based on conditions in Power BI.
https://www.spguides.com/create-table-using-power-query/ 20/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
For example, if the Age is greater than 16 and less than 40, then we will get True else
False. So we will use the custom column to display the result.
In Power Query Editor, Go to Add column tab-> Custom column from the ribbon.
Now Custom column window will open, then provide the name of the column.
And write the below formula using AND operator. Then click on OK.
https://www.spguides.com/create-table-using-power-query/ 21/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now you can see the result in the custom column, the result can be true or false.
This is an example of how to use power query and operator in Power BI.
https://www.spguides.com/create-table-using-power-query/ 22/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
So, to append two or more tables or queries we will use the Append operation, which
creates a new table that has all rows from the first table followed by the second table.
The Append queries operation is based on the column header in both tables but it does
not need the relative column position. If the table does not carry a similar column then
null values get added to the unsimilar column.
Let’s say we have two tables like below, one is Emp table and Emp table 2, so we will
append both tables and create a new table.
Emp table
Emp table 2
In the Power Query editor, go to the Home tab-> select the Append Queries->
select Append Queries as new.
https://www.spguides.com/create-table-using-power-query/ 23/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Then Append window will open, select the two table option. Then select the first
table and then select the second table. Then click on Ok.
https://www.spguides.com/create-table-using-power-query/ 24/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now you can see the new table by appending both tables using Power Query
Editor in Power BI.
This is an example of how to use power query append tables in Power BI.
We will use the reference method to create a table from another table using the Power
Query Editor in Power BI. Reference in Power query is used to query a query, which
means you will use the result query in some other queries where your primary query
remains as a base query.
Let’s say we will create a table from the below table, which will consist of the Name
and Age column from the below table.
https://www.spguides.com/create-table-using-power-query/ 25/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
In Power Query Editor, in the left side pane under Queries-> select the table or
queries-> right-click on it-> click on Reference option.
https://www.spguides.com/create-table-using-power-query/ 26/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now you can see another table created and has the same data. Now select the
column Department and go to Home tab-> Remove columns-> Remove columns.
Now you can see the new table created from another table using the Power Query
editor in Power BI.
This is an example of how to use power query reference another table in Power BI.
https://www.spguides.com/create-table-using-power-query/ 27/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
We have below tables with 2 columns i.e. Segment and Sale, so here we will pivot the
table based on the segment column and the value will be the Sales.
https://www.spguides.com/create-table-using-power-query/ 28/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
In Power Query Editor, select the segment column-> go to the Transform tab->
click on the Pivot column option
Next Pivot column window will open, choose the value column as sales. Then
click on Ok.
Now you can see the table converted into the pivoted table which has multiple
columns.
https://www.spguides.com/create-table-using-power-query/ 29/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
This is an example of how to use a power query by multiple columns in Power BI.
In the below table we will insert a new row in row 1, as in the Power query editor row
count start from 0.
To insert a row we will use the Advanced Editor in Power Query Editor.
In Power Query editor, go to the Home tab-> select the Advanced Editor from the
ribbon.
Then Advance Editor window will open, then write the below queries to insert
row.
https://www.spguides.com/create-table-using-power-query/ 30/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
NewRows =Table.InsertRows(
Table.FromRecords({
[Name = "Alex", Department= "IT", Age =38],
[Name = "John", Department= "Finance", Age =16]
}),
1,
{[Name = "Bob", Department= "Finance", Age =45]}
)
Then under the in write the NewRows and then click on Done.
Now you can see a row is inserted in position 1 of the table in Power Query Editor.
https://www.spguides.com/create-table-using-power-query/ 31/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
In Query editor to merge or combine two more columns, we will use the merge
columns option. The column must have a text data type.
For this example, we will use the below table and combine the First name and Last
name columns from the table into one column.
In the Power Query editor, first, we will select the two-column from the table. To
select press Ctrl and select the column you want to merge.
Then go to the Transform tab-> click on the Merge columns from the ribbon.
https://www.spguides.com/create-table-using-power-query/ 32/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
You can see the Merge column window will open. Provide the separator, and
then give a new column name.
Now you can see both the columns are merged into one in Power Query Editor.
https://www.spguides.com/create-table-using-power-query/ 33/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
This is an example of how to use a power query to add rows in Power BI.
To create a calendar table in Power Query Editor follow the below steps:
In the Power Query editor, click on the Enter data from the ribbon, to create a
calendar table. Then provide the column names as Start Date and then add a
start date value, from which date you want to start. Rename the table and click
on OK.
https://www.spguides.com/create-table-using-power-query/ 34/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now we need to add the Last Date column, so go to Add column tab-> select the
Custom column option.
A custom column window will open, then provide the name as the Last date.
Next, provide the below formula to get the current date as the last date:
Date.From(DateTime.LocalNow()
https://www.spguides.com/create-table-using-power-query/ 35/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Then change the data type of the Last date to date data type.
Now we get the start date and last date, now we will create a list of dates
between the start date and last date.
So, go to the Add column tab-> select the Custom column from the ribbon.
Then the custom column window will open, provide the column name as Date.
Then provide the formula below to get the list of dates between the start date
and the last date.
https://www.spguides.com/create-table-using-power-query/ 36/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now we will expand the column to create a new row, so click on the Expand icon
in the column->Expand to new rows from the option.
Now you can see the date from the start date to the last date in the column.
Now change the data type of the date column to date.
https://www.spguides.com/create-table-using-power-query/ 37/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now remove the start date and last date column from the table. Select both the
column and then click on remove from the ribbon.
Next, we will add the year, month, quarter, week, and day column. So, for this
right-click on the date column and select the Duplicate column.
Select the Duplicate column and right-click on it-> Transform-> Year->Year from
the option.
Then rename the column to Year.
https://www.spguides.com/create-table-using-power-query/ 38/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Similarly, you can add other columns after that your calendar table is created.
https://www.spguides.com/create-table-using-power-query/ 39/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
This is an example of how to use the power query to create a calendar table in Power
BI
With the help of the List function in the M query i.e. List.PositionOf(), we can get the
value, or we will lookup for the value from another table. For Example, we have two
sample table
1. Product table: The Product table has three columns these are Product Name,
Order Date, and Price.
Power BI how to use power query get value from another table
https://www.spguides.com/create-table-using-power-query/ 40/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
In Power BI how to use power query to get value from another table
So, we will get the category value into the Product table, for this, we need to create a
category index in the product table based on the category in the Categories table.
Then we will fetch the category value to the Product table with the help of the
Category index.
In Power Query editor,-> select the Product table-> go to Add column tab-> select
the Custom column option.
Then Custom column window will open. Rename the column as Category index
and write the formula in the Formula box. Click on OK
List.PositionOf(Categories[Product],[Product name])
https://www.spguides.com/create-table-using-power-query/ 41/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Power BI how to use power query lookup value from another table
Now you can see the index created in the Product table based on the category column
in the Categories table.
Microsoft Power BI how to use power query lookup value from another table
To get the category value, create another custom column and then rename the
column as Category. Provide the below formula to get the value:
https://www.spguides.com/create-table-using-power-query/ 42/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Categories[Category]{[Category index]}
Now you can see the category value is added to the Product table.
https://www.spguides.com/create-table-using-power-query/ 43/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
This is an example of how to use the Power query lookup value from another table in
Power BI.
The inner join feature will merge both the tables for the matching rows only. For
example, we have two tables these are Product table and the Categories table.
Products table
https://www.spguides.com/create-table-using-power-query/ 44/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Categories table
In Power Query Editor, click on the Merge queries-> Merge Queries from the
ribbon.
https://www.spguides.com/create-table-using-power-query/ 45/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Then the Merge queries window will open, select the second table, in this case,
it is the Categories table.
Then select the product name column from the Product table and product from
the Categories table.
Then in the Join Kind section select the Inner (Only matching rows). Click on Ok.
https://www.spguides.com/create-table-using-power-query/ 46/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Next, expand the table, so click on the arrow icon and then select the Expand, and
unselect the product field, because we already have the product field. Then click on
Ok.
Next, you can see both the tables are merged into a single table.
https://www.spguides.com/create-table-using-power-query/ 47/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
In the Power Query editor, first, select a column and then press Ctrl+ click on the
columns you want to select.
We have two tables one is Product 1 and another is Product 2, so we will see how to
select multiple columns while joining both the table.
Product 1
https://www.spguides.com/create-table-using-power-query/ 48/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Product 2
In Power Query Editor, click on the Merge queries-> Merge queries as new.
Then Merge queries windows will open, and select the table you want to merge.
To select multiple columns, press ctrl and click on the columns, you want to
choose in both the table.
Then select the join from the options and click on ok.
https://www.spguides.com/create-table-using-power-query/ 49/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Click on the icon to expand the table-> select the Expand option and choose the
column you want to display.
https://www.spguides.com/create-table-using-power-query/ 50/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now, you can see the two tables join on multiple columns using the Power query
editor.
This is an example of how to use power query join on multiple columns in Power BI.
https://www.spguides.com/create-table-using-power-query/ 51/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
For this example, we have two tables one is the Product table and the Order table, we
will union tables using the Append queries feature in Power Query.
Product table
Order table
To union the two tables, in the Power Query editor, click on the Append queries->
select Append queries as new from the ribbon.
Append queries window will open, select the Two tables and then select the
First table and second table. Click on Ok.
https://www.spguides.com/create-table-using-power-query/ 52/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now you can see the union of tables in the Power Query editor.
This is an example of how to use power query union tables in Power BI.
https://www.spguides.com/create-table-using-power-query/ 53/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Unpivoting is the process that will convert the column name into a single column into
rows and the values are transformed into a single column.
For this example, we have a pivot table i.e. product table having a header or column
name based on the product and value based on price.
In the Power Query editor, select the Transform tab-> then select all columns
with ctrl +click on the column.
Once you select all the columns, in the Transform tab click on the Unpivot
Columns-> Unpivot Columns from the option.
https://www.spguides.com/create-table-using-power-query/ 54/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now you can see the table is unpivoted, the column header is converted into a single
column, and the values also.
This is an example of how to use power query count rows in Power BI.
To remove the 1st and 2nd rows from the below table using the Power Query editor in
Power BI.
Power BI how to use power query remove rows based on the value
https://www.spguides.com/create-table-using-power-query/ 55/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
In the Power Query editor, select the column and go to the Home tab-> click on
Remove rows.
There are 6 different options, you can remove the rows from the table based on
your need.
In this case, we will select Remove Top rows-> Remove Top rows window will
open. Provide the number of rows you want to remove from the top. Click on Ok.
Microsoft Power BI how to use power query remove rows based on the value
Now you can see the rows are removed from the table in the Query Editor.
This is an example of how to use power query to remove rows based on the value in
Power BI
https://www.spguides.com/create-table-using-power-query/ 56/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
We will use the below table to change the age of Ron Smith from 23 to 25 by using the
Replace values method.
In Power Query Editor, go to the Home page, and select the value from the
column.
Then click on Replace values option from the ribbon.
Next, the Replace value windows will open, so here you can see the value under
the Value to Find option, and under Replace with option write the value you
want to replace.
https://www.spguides.com/create-table-using-power-query/ 57/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Next, you can see the 23 value is replaced with 25 in the Age column.
This is an example of how to use the Power query to replace values in Power BI.
Here we will see how to sort data on multiple columns using the Power Query editor in
Power BI.
With the help of the sort feature, you can arrange the data in ascending order(A-Z) or
descending order(Z-A).
For this example, we will use the below table and sort the name column based on that
it will sort the other column.
To sort the multiple columns in the Power Query editor, follow the steps below:
In the Power Query editor, click on the column based on which you want to sort
the other columns.
Then in the Home tab, click on the Az icon in the Sort section, or else you can
sort the column by clicking on the down arrow next to the column name-> Select
Sort Ascending.
https://www.spguides.com/create-table-using-power-query/ 59/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
In this case, I have sorted the name in the Ascending order, i.e. A to Z, based on
that other columns are sorted accordingly.
https://www.spguides.com/create-table-using-power-query/ 60/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
This is an example of how to use a power query to sort multiple columns in Power BI.
We will create a new custom column and then calculate the sum of the price from the
below table.
To get the sum of the Price column follow the below steps:
In the Power Query editor, go to the add column tab, then click on the Custom
column from the ribbon.
Then the custom column window will open, provide the column name and then
provide the below formula.
List.Sum(#"Changed Type"[Price])
https://www.spguides.com/create-table-using-power-query/ 61/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now you can see the output of the sum of the price column in the Power query.
This is an example of how to use Power query to sum column in Power BI.
https://www.spguides.com/create-table-using-power-query/ 62/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Here we will see how to count rows using the Power Query editor in Power BI.
To see the count rows for each column in the Power query editor.
In the Power Query editor, go to the View tab-> then select the Column Profile option
from the ribbon. Now you can see the count rows of each column.
https://www.spguides.com/create-table-using-power-query/ 63/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
This is how to use count rows using Power Query in Power BI.
For this example, we will use the below table to replace the null value in the Price
column with 0 using the Query Editor in Power BI.
To replace the null value with 0 in the Power Query editor, follow the below steps:
In the Power Query editor, go to the Home tab-> select the Price column-> then
click on the Replace values.
Then Replace window will open, provide the value which will be replaced i.e.
null, then provide the value you want to replace with i.e. 0.
https://www.spguides.com/create-table-using-power-query/ 64/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now you can see the null value is replaced with 0 using the Power Query editor
in Power BI.
This is an example of how to use a power query to replace the null value in Power BI.
Here we will see how to get the previous row data using the Power Query editor in
Power BI.
For this example, we have the below table and we will get the previous row value of
the price column.
To get the value of the previous row in the Power Query editor, follow the below steps
First, we will sort the column, to sort the Price column, click on the arrow then
select the Sort ascending option.
https://www.spguides.com/create-table-using-power-query/ 66/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Microsft Power BI how to use power query get the previous row
Then we will add the index column, and go to Add column tab-> Index column->
From 0 from the ribbon.
In Microsft Power BI how to use power query to get the previous row
To get the previous row we will add 1 to the index, so select the index column->
to go to Add column tab-> click on the Standard -> select Add.
https://www.spguides.com/create-table-using-power-query/ 67/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Then Add window will open, and provide 1 in the Value field. Click on Ok.
Next, we will Merge the table with itself, so select the Merge queries from the
Home tab.
Then Merge queries window will open, and select the same table to merge.
Then select the Index column( first table) and select the Addition
column(Second table)
Select join as Left Outer. Click on OK.
https://www.spguides.com/create-table-using-power-query/ 68/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Then click on the icon-> select the Expand option-> select the Price column->
click on Ok.
https://www.spguides.com/create-table-using-power-query/ 69/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Now you can see the previous value of the price column in the Power query
editor.
This is an example of how to use the power query to get the previous row in Power BI.
For this example, we will use the below table and remove the null or blank rows from
the table.
https://www.spguides.com/create-table-using-power-query/ 70/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
In the Power Query editor, go to the Home tab-> select Remove rows-> Remove
Blank Rows from the ribbon.
Now you can see the blank or null rows are removed from the table.
This is an example of how to use a power query to remove null rows in Power BI.
https://www.spguides.com/create-table-using-power-query/ 71/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
Conclusion
In this Power BI tutorial, we learned how to create a table in the Power Query editor
and also we discuss the below example:
Bijay Kumar
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have
more than 17 years of expertise in SharePoint Online Office 365, SharePoint
subscription edition, and SharePoint 2019/2016/2013. Currently working in
my own venture TSInfo Technologies a SharePoint development, consulting,
and training company. I also run the popular SharePoint website EnjoySharePoint.com
Name
Join the
Newsletter & Email Address
Download 122
https://www.spguides.com/create-table-using-power-query/ 73/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
EnjoySharePoint
YouTube 16K
https://www.spguides.com/create-table-using-power-query/ 74/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
https://www.spguides.com/create-table-using-power-query/ 75/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
https://www.spguides.com/create-table-using-power-query/ 76/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
https://www.spguides.com/create-table-using-power-query/ 77/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
https://www.spguides.com/create-table-using-power-query/ 78/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
https://www.spguides.com/create-table-using-power-query/ 79/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
https://www.spguides.com/create-table-using-power-query/ 80/81
2/25/24, 10:21 PM Create table using Power Query in Power BI [With 31 real examples] - SPGuides
2024 © SPGuides.com
https://www.spguides.com/create-table-using-power-query/ 81/81