Power BI Trending

Power Query Tutorial: Transforming Data Without Code

A working tutorial for Power Query in Power BI Desktop: the applied-steps model, the profiling setting that hides problems, data types, the unpivot option that survives refresh, query folding, and how to structure queries so a report still refreshes next month.

GloryTecks Team

Training & Placement Faculty

1 June 2026 7 min read

Last updated: 24 September 2026

Share:

Power Query is the data-preparation engine inside Power BI Desktop (and Excel, and several Microsoft data services). You connect to a source, shape the data through menus, and every action is recorded as a step that re-runs on each refresh (Microsoft Learn: what is Power Query?). "Without code" is only half true. Every click writes a line of M code. Knowing what those steps do is the difference between a report that refreshes cleanly next month and one that breaks the first time the source changes.

This tutorial follows one realistic job: a monthly sales export (CSV) with a date column per month, messy types and a few blank rows, shaped into a table Power BI can model.

Opening Power Query Editor

In Power BI Desktop, choose Get data to connect, then Transform data on the Home tab to open Power Query Editor instead of loading straight into the model. When the query is ready, Close & Apply loads it (Microsoft Learn: query overview in Power BI Desktop). Loading without transforming is the most common beginner mistake: it pushes the raw file, blank rows, text-typed numbers and all, into the model, where fixing it is harder.

Applied steps are a recipe, not a history

Every transformation appears in the Applied steps list on the right. On refresh, Power Query does not replay your clicks against a stored result. It runs the recipe again, from the source, top to bottom (Microsoft Learn: applied steps). Three habits follow from that:

  • Rename steps that matter. Right-click a step, then Properties. "Removed blank CustomerID rows" says what "Filtered Rows 2" does not.
  • Delete carefully. Later steps often refer to columns an earlier step created. Delete until end removes a step and everything after it when you need to rebuild from a point.
  • Insert, don’t append, when you fix something. Right-click a step and Insert step after to put a fix where it belongs, instead of patching at the end.

Turn on profiling, for the whole column

On the View tab, enable Column quality, Column distribution and Column profile. Column quality labels each column’s values as valid, error or empty, so a text value in a number column shows up immediately (Microsoft Learn: data profiling tools).

The 1,000-row default

By default, profiling looks only at the first 1,000 rows. A column can show 100% valid while row 50,000 holds an error. Select Column profiling based on top 1000 rows in the status bar and switch it to entire data set before trusting the numbers.

Set data types deliberately

For files such as CSV and TXT, Power Query detects types automatically, often adding a Changed Type step right after the source (Microsoft Learn: data types). Check it rather than accept it. A postcode or product code typed as a whole number loses its leading zeros. A date read with the wrong locale swaps day and month. Type-specific filters, such as the date filters, are not even offered until a column has the right type.

Set types once, in a step you name, after you have removed header junk and blank rows, and before calculations that depend on them.

The transformations you will use most

TaskWhereWatch out for
Use the first row as headersHome → Use First Row as HeadersExports with a title row above the headers: remove top rows first
Remove blank or junk rowsHome → Remove Rows"Remove blank rows" only removes rows where every column is empty
Filter rowsColumn header drop-downFilter early: fewer rows for every later step
Split a columnTransform → Split ColumnSplitting by delimiter into a fixed number of columns ignores extra parts
Replace valuesTransform → Replace ValuesIn text columns it replaces every occurrence inside a cell ("NA" also changes "NATIONAL") unless you tick Match entire cell contents under Advanced (Microsoft Learn)
Merge queries (join)Home → Merge QueriesCheck key types match; text "101" does not join to number 101
Append queries (union)Home → Append QueriesColumns are matched by name; a renamed column becomes a new, mostly empty column
Group ByTransform → Group ByAggregating here fixes the grain of the table; keep detail if the report needs it

Unpivot: pick the option that survives next month

Our sales export has one column per month: Product | Jan-2026 | Feb-2026 | …. Power BI wants one row per product per month: Product | Month | Sales. That is an unpivot, and Power Query offers three versions:

CommandWhat it recordsWhen next month’s column appears
Unpivot other columns (select Product)Keep Product, unpivot everything elseThe new month is unpivoted automatically
Unpivot columns (select the month columns)Recorded the same way: keep the unselected columnsThe new month is unpivoted automatically
Unpivot only selected columnsUnpivot exactly the columns you selectedThe new month stays as its own column

The first two produce the same result and adapt when the source gains columns (Microsoft Learn: unpivot columns). Use Unpivot other columns on the columns that identify a row. Then rename the generated Attribute and Value columns to Month and Sales, and set their types.

Query folding: why step order matters

When the source is a database, Power Query tries to translate your steps into the source’s own query language, SQL for example, so the database does the filtering and aggregating. This is query folding, and the outcome is full, partial or none (Microsoft Learn: query folding basics). Connectors such as SQL Server and OData commonly fold. Files such as CSV and Excel have no query engine and never fold, so for them every step runs in Power Query.

  • Put filters and column removal early, while the query still folds. The database then sends fewer rows.
  • Some steps stop folding, and every step after them runs locally. Keep such steps late.
  • Right-click a step and choose View Native Query. If it is available, that step folds and you can read the SQL being sent.

Structure queries so the report can be maintained

Microsoft’s best-practice guidance favours several small queries that reference each other over one long query (Microsoft Learn: Power Query best practices). A layout that works for most reports:

  1. Source queries: connect and apply only the fixes every consumer needs (headers, types, blank rows). Right-click → untick Enable load so they do not become model tables.
  2. Shaping queries: right-click a source query → Reference, and build the fact and dimension tables from it.
  3. Parameters for anything that changes between environments or months: file paths, server names, a cut-off date.

To see what this produces, open View → Advanced Editor. A short query for the sales file reads like this. Each line is one applied step, and each step refers to the one before it:

powerquery
let
    Source = Csv.Document(File.Contents(SalesFilePath), [Delimiter = ",", Encoding = 65001, QuoteStyle = QuoteStyle.Csv]),
    PromotedHeaders = Table.PromoteHeaders(Source, [PromoteAllScalars = true]),
    RemovedBlankProducts = Table.SelectRows(PromotedHeaders, each [Product] <> null and [Product] <> ""),
    UnpivotedMonths = Table.UnpivotOtherColumns(RemovedBlankProducts, {"Product"}, "Month", "Sales"),
    TypedColumns = Table.TransformColumnTypes(UnpivotedMonths, {{"Product", type text}, {"Month", type date}, {"Sales", type number}})
in
    TypedColumns

SalesFilePath is a parameter, so pointing the report at next month’s file is a one-value change. Converting a "Jan-2026" header into a real date may need your locale, or an extra step if the header format is unusual. Reading and writing M directly is covered in Power Query M language basics. Handling cells that fail conversion is covered in error handling in Power Query.

Power Query or DAX?

A useful default: shape and clean in Power Query, calculate in DAX. Columns that describe a row and never change with the report’s filters, such as a cleaned product name or a month key, belong in Power Query, so they are computed once at refresh. Totals, ratios and time comparisons that must respond to slicers belong in DAX measures; see DAX: measures, calculated columns and context.

Does Power Query change my source file?

No. Power Query reads from the source and applies its steps to the loaded copy; the source file or table is not modified.

Why did my refresh fail after the source changed?

Usually a step refers to a column by name, and the column was renamed or removed in the source. Find the first step showing an error in Applied steps; the steps after it fail because of it.

Is Power Query in Excel the same as in Power BI?

The engine and the M language are the same, and most menus match. If you work in Excel, see cleaning data with Power Query in Excel.

Should I remove columns I do not need?

Yes, and early. Fewer columns mean a smaller model and faster refresh, and with a database source the removal usually folds into the query.

Where to go next

Data transformation with Power Query is a core module of our Power BI course, followed by data modelling and DAX.

Sources

GloryTecks Team

Training & Placement Faculty

The GloryTecks faculty team mentors learners across Data Science, AI and Data Engineering, with a focus on real-time projects and placement readiness in Hyderabad.

Want to master Power BI?

Join GloryTecks’ expert-led Power BI training in Hyderabad with real-time projects and 100% placement support.

Explore course