Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training
Data Analytics⏱️ 13 min readπŸ“… Nov 26

Power Query Tutorial (2026): Clean and Transform Data in Power BI

RM
Rohit Malhotraβ€’BI Developer
πŸ“‘ Contents (29 sections)

πŸ“ŒWhat Is Power Query?

Power Query is the data preparation engine inside Power BI, Excel, Dataflows and Microsoft Fabric. You connect to a source, clean and reshape the data through a visual editor, and each action is recorded as an Applied Step. On refresh, those steps replay automatically, so a messy monthly file becomes a one click job.

Under the hood, every step is written in the M language. You can build most transformations without writing M, but reading it makes you much faster.

In real projects, Power Query work is often 60 to 80 percent of the effort. Getting it right makes the model and DAX simple. New to Power BI? Start with the Power BI tutorial for beginners.

πŸ“ŒOpening the Power Query Editor

In Power BI Desktop, choose Home, Transform data. You will see:

  • Queries pane on the left: one query per table.
  • Data preview in the middle.
  • Applied Steps on the right.
  • Formula bar showing the M code of the selected step (turn it on under View).
  • Turn on Column quality, Column distribution and Column profile in the View tab. Profiling shows errors, empty values and unique counts before they become problems. By default it profiles the first 1,000 rows; switch to the entire dataset at the bottom of the window when checking quality.

    πŸ“ŒEssential Transformations

    Data types

    Set types deliberately: Whole Number for IDs, Decimal or Fixed Decimal for money, Date for dates, Text for codes like PIN codes and phone numbers. Wrong types are the top cause of broken relationships.

    Remove and keep rows

    Remove top rows (report headers in exported files), blank rows, duplicates and errors. Keep Rows can keep top N or a range.

    Text cleanup

    Trim removes leading and trailing spaces, Clean removes non printing characters, and Capitalize Each Word standardises names. Use Replace Values for known bad values.

    Split and merge columns

    Split by delimiter, number of characters or positions. Merge columns to build keys such as Year and Month.

    Fill down

    Exported reports often show a value only in the first row of a group. Fill Down copies it into the blank rows below.

    Conditional and custom columns

    Conditional Column builds IF logic without code. Custom Column accepts M expressions:

    = if [Quantity] >= 10 then "Bulk" else "Standard"
    = [Quantity] * [UnitPrice]
    = Date.Year([OrderDate])

    Column from examples

    Type the result you want for a couple of rows and Power Query writes the transformation for you. Excellent for extracting codes from text.

    πŸ“ŒCombining Data: Merge and Append

    Append queries

    Append stacks tables with the same columns, for example Sales 2024 and Sales 2025. It is the Power Query version of SQL UNION ALL.

    Merge queries

    Merge joins two tables on matching columns, like SQL JOIN. Join kinds:

  • Left outer: all rows from the first table, matches from the second (most common)
  • Right outer, Full outer, Inner
  • Left anti / Right anti: rows with no match, perfect for finding missing products or customers
  • After merging, expand only the columns you need. Use fuzzy matching when keys have small spelling differences.

    Combine files from a folder

    Point Get Data, Folder (or SharePoint folder) at a directory of monthly files with the same layout. Power Query builds a function that processes every file and appends them. Drop next month's file in the folder, refresh, done.

    πŸ“ŒReshaping: Pivot, Unpivot, Group By

    Unpivot

    Finance and planning sheets often arrive wide, with one column per month. Power BI wants them long. Select the ID columns, then Unpivot Other Columns to get Attribute (month) and Value columns. This single skill fixes most budget versus actual reports.

    Pivot

    The reverse: turn row values into columns. Use sparingly in a model; long tables usually work better.

    Group By

    Aggregate rows, for example total quantity per order. In a star schema you usually keep detail and aggregate in DAX instead, but Group By is useful for summary tables and deduplication.

    πŸ“ŒParameters and Functions

    Parameters store values such as a server name, a file path or a date cutoff, so you can switch from dev to prod without editing every query. They are also required for incremental refresh (RangeStart and RangeEnd).

    You can turn any query into a custom function and invoke it per row, which is how folder combine works.

    πŸ“ŒA Taste of the M Language

    Each query is a let ... in expression:

    let
    Source = Excel.Workbook(File.Contents(FilePath), null, true),
    Sales = Source{[Item = "Sales", Kind = "Sheet"]}[Data],
    Promoted = Table.PromoteHeaders(Sales, [PromoteAllScalars = true]),
    Typed = Table.TransformColumnTypes(Promoted, {
    {"OrderDate", type date}, {"Quantity", Int64.Type}, {"UnitPrice", type number}
    }),
    Added = Table.AddColumn(Typed, "SalesAmount", each [Quantity] * [UnitPrice], type number)
    in
    Added

    M is case sensitive, and the each keyword is shorthand for a function applied to every row.

    πŸ“ŒQuery Folding: The Performance Secret

    Query folding means Power Query translates your steps into the source's native language, usually SQL, so the database does the work. Folding makes refreshes fast and is required for efficient incremental refresh.

  • Right click a step and check View Native Query, or look at the folding indicators in the Applied Steps pane.
  • Filters, column removal, renames, simple merges and group by usually fold.
  • Adding an index column, some custom M functions, and certain type changes can break folding.
  • Put non folding steps as late as possible, and push heavy logic into a SQL view when you can.
  • Strong SQL makes folding far easier to reason about; see SQL for Data Analytics.

    πŸ“ŒPower Query Best Practices

  • 1Rename steps meaningfully, for example "Removed blank customers".
  • 2Remove unneeded columns early; fewer columns means a smaller, faster model.
  • 3Filter rows early, especially on large sources.
  • 4Disable load for staging queries you only use to build other queries.
  • 5Keep types explicit and set them once near the end of each query.
  • 6Use parameters for paths and servers.
  • 7Document tricky steps with comments in the Advanced Editor.
  • After Power Query, the next step is modelling: read our star schema guide.

    πŸ“ŒFrequently Asked Questions

    Is Power Query the same in Excel and Power BI?

    Yes, the same engine and M language. Skills transfer directly, which is why our Excel for data analysis guide recommends learning it early.

    Should I clean data in Power Query or DAX?

    Power Query (or upstream in SQL). DAX is for calculations on a clean model. A rule many teams follow: transform as far upstream as possible, as far downstream as necessary.

    What is the difference between merge and append?

    Merge adds columns by joining tables on a key. Append adds rows by stacking tables with the same columns.

    Do I need to learn M code?

    Not to start. Reading M and making small edits in the Advanced Editor is a big productivity gain later.

    Is Power Query tested in PL-300?

    Yes, under preparing the data. See our PL-300 guide.

    πŸ“ŒLearn It Live

    Prakalpana's Power BI course is taught live online with an optional 1-on-1 track, using messy real business files for Power Query practice, then modelling, DAX and publishing. See the Power BI learning path, then WhatsApp or call +91 9180377502 for a free demo.

    RM

    Written by

    Rohit Malhotra

    BI Developer

    πŸš€ Master Data Analytics

    Live online + 1-on-1 Power BI training Β· Join 5000+ developers

    Not sure what to do? Book career counselling (β‚Ή200 / 30 min)

    Not sure what to learn next?

    A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

    1. 1Discuss your goals
    2. 2Get a personal plan
    3. 3Start learning
    Book for β‚Ή200/ 30 min