π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:
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: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 AddedM 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.
Strong SQL makes folding far easier to reason about; see SQL for Data Analytics.
πPower Query Best Practices
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.