+91 99301 12627
Power BI & Tableau

Power Query Tutorial for Beginners: Clean and Shape Data in Excel and Power BI

By Mehul Prajapati

Connected metal pipes representing data flowing through Power Query transformations
On this page

Power Query is the data-preparation engine built into Excel and Power BI. It lets you connect to a source (Excel, CSV, SQL, a folder of files, a web page), clean and reshape the data with point-and-click steps, and then refresh the whole process with one click when new data arrives. If you spend hours every month copying, pasting and fixing the same report, Power Query is the tool that gives those hours back.

This tutorial is written for beginners. By the end you will know where Power Query lives, the transformations you will use most, how merge and append differ, what the M code behind each step looks like, and how Power Query fits with DAX in Power BI.

What is Power Query?

Power Query is an ETL tool: it Extracts data from a source, Transforms it, and Loads it into an Excel sheet or a Power BI data model. Every action you take (remove a column, change a data type, filter rows) is recorded as an Applied Step. Behind the scenes, those steps are written in a functional language called M. You do not need to write M to use Power Query, but being able to read it helps a lot when something breaks.

The key idea: you never edit the source file. Power Query keeps the raw data untouched and replays your recorded steps every time you refresh.

Where to find Power Query

  • Excel (2016 and later, Microsoft 365): Data tab → Get Data (or From Table/Range for data already in the sheet). This opens the Power Query Editor.
  • Power BI Desktop: Home tab → Get Data to connect, then Transform Data to open the Power Query Editor.

The editor has four areas you will use constantly: the Queries pane (left), the data preview (centre), the Applied Steps list (right) and the formula bar, which shows the M code for the selected step. Turn the formula bar on from View → Formula Bar if you cannot see it.

The 12 transformations you will use every day

  1. Use First Row as Headers – promotes the first row to column names.
  2. Change Type – sets each column to text, whole number, decimal, date and so on. Wrong types are the most common cause of errors later.
  3. Remove Columns / Choose Columns – keep only what the report needs. Fewer columns means a faster model.
  4. Remove Duplicates – on one column (like an order ID) or a combination of columns.
  5. Filter Rows – drop blanks, test records or old years using the column drop-down.
  6. Replace Values – fix inconsistent spellings such as “Mumbai”, “mumbai” and “Bombay”.
  7. Trim and Clean – Transform → Format removes extra spaces and non-printing characters that make two identical-looking values different.
  8. Split Column – by delimiter or number of characters, for example splitting “Borivali, Mumbai” into area and city.
  9. Fill Down – fills blank cells with the value above, typical in exported reports where the category is printed only once.
  10. Add Column from Examples / Custom Column – create new columns such as Profit = Revenue − Cost or a Month Name from a date.
  11. Group By – summarise rows, for example total sales per region.
  12. Unpivot Columns – turns wide tables (Jan, Feb, Mar as separate columns) into a long table with Month and Value columns, which is the shape Power BI and pivot tables work best with.

Merge vs Append: combining queries

Feature Merge Queries Append Queries
What it does Joins two tables side by side on a matching column Stacks tables one below the other
SQL equivalent JOIN UNION ALL
Typical use Add customer name to an orders table using Customer ID Combine January, February and March sales files
Requirement A common key column Same (or similar) column names

Merge offers the same join kinds you learn in SQL: left outer, right outer, full outer, inner, left anti and right anti. If joins are new to you, read our guide on SQL joins explained first; the logic is identical.

Tip: to combine every file in a folder, use Get Data → Folder → Combine. Drop next month’s file into the folder, press Refresh and it is included automatically.

A small worked example

Suppose you receive a monthly sales export with a title row at the top, extra spaces in the City column, duplicate order lines and amounts stored as text. In Power Query you would: remove the top row, promote headers, trim City, change Amount to a decimal number and OrderDate to a date, then remove duplicates on OrderID. The M code Power Query writes for you looks like this:

let
    Source = Excel.CurrentWorkbook(){[Name="Sales"]}[Content],
    Promoted = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    Typed = Table.TransformColumnTypes(Promoted, {{"OrderDate", type date}, {"Amount", type number}}),
    Trimmed = Table.TransformColumns(Typed, {{"City", Text.Trim, type text}}),
    NoDupes = Table.Distinct(Trimmed, {"OrderID"})
in
    NoDupes

Each line is one Applied Step, and each step uses the result of the step before it. That is all M really is: a chain of named steps between let and in.

Power Query vs DAX: which one should do the work?

In Power BI, beginners often ask whether a calculation belongs in Power Query or in DAX. A simple rule works well:

  • Power Query for shaping and cleaning: fixing types, removing rows, splitting, merging, unpivoting and creating columns that do not change with report filters.
  • DAX for calculations that respond to filters and slicers: total sales, year-to-date, percentage of total, running totals.

Clean as far upstream as possible. A column created in Power Query is computed once at refresh; a measure in DAX is computed every time someone clicks a slicer. Our DAX functions for beginners guide covers the second half of this workflow.

Common beginner mistakes

  • Changing types too early and too often. Power Query adds an automatic Changed Type step; check it, and set types once after headers are correct.
  • Hard-coded file paths. If a colleague opens the file from a different folder, refresh fails. Use a parameter for the path.
  • Loading every helper query. Right-click staging queries and untick Enable Load so they do not bloat the model.
  • Renaming columns in the source later. Steps refer to column names, so a renamed source column breaks the query. Fix it in the step that references it.
  • Not checking column quality. Turn on View → Column quality and Column distribution to spot errors and empty values before you load.

Practice exercise

Download any public dataset with monthly columns (for example a state-wise or product-wise sales table). In Power Query: remove empty rows, unpivot the month columns, convert the month text to a proper date, group by year to get annual totals, and load the result to a new sheet. Then add next month’s data to the source and refresh. If the numbers update without you touching anything, you have understood Power Query. Turn the result into a dashboard using one of our Power BI projects for beginners.

Frequently asked questions

Is Power Query the same in Excel and Power BI?

Almost. The editor, the transformations and the M language are the same. Power BI has a few extra connectors and features, and the destination is different: Excel loads to a sheet or the Data Model, while Power BI loads to its data model.

Do I need to learn M code?

Not to start. Most daily work is point-and-click. Learning to read M becomes useful when you want to fix a broken step, use parameters or write a custom function.

Can Power Query replace VBA macros?

For importing, cleaning and combining data, usually yes, and it is easier to maintain. VBA is still needed for tasks such as automating formatting, sending emails or controlling other applications.

How long does it take to learn Power Query?

With regular practice, most learners are comfortable with the core transformations in one to two weeks. Merge, append, unpivot and parameters take a little longer to feel natural.

Want guided practice on real business datasets? Power Query, data modelling and DAX are covered hands-on in our Power BI course and Advanced Excel course.

A note from Mehul Prajapati

I have spent 18+ years in IT and training and have personally mentored 12,000+ students. If you are planning your next step in Power BI and data analytics and want a second opinion on your learning path, I am happy to help.

“The technology you learn today may change tomorrow, but your ability to learn will always be your biggest strength. Stay curious, keep upgrading yourself, and never stop growing.”

Message me on WhatsApp at +91 99301 12627 and tell me which blog you read. I would love to hear from you.

Learn with Mehul Prajapati in Borivali West

At Mehul Prajapati’s institute, you get 100% practical, hands-on training by industry experts with a minimum of 5+ years of experience, plus placement assistance on the Power BI course. Weekday and weekend batches are available, with multiple 2-hour slots between 8 am and 6 pm.

Address: 12th Floor, 1214, Gold Crest Business Centre, LT Rd, Above Westside Showroom, Borivali West, Mumbai, Maharashtra 400092
Call: +91 99301 12627 / +91 96645 45072

Visit the centre or call us to choose the right course and batch and to know the current fee structure.