Work & productivity / QUICK REFERENCE
Power Query: clean, merge and reshape data
Compact Power Query Editor tasks and M expressions for cleaning columns, unpivoting, joins and grouping.
Open and prepare a table
- Open Power Query in Excel
- Data → Get Data
Choose an external or workbook source before transforming. [1][5][4]
- Turn values into headers
- Home → Use First Row as Headers
Promote first data row when it contains column labels. [1][5][4]
- Change column type
- Transform → Data Type
Choose Text, Whole Number, Decimal Number, Date or similar type. [1][5][4]
- Explicit numeric type in M
Table.TransformColumnTypes(Source,{{"Amount",type number}})- Explicit date type in M
Table.TransformColumnTypes(Source,{{"Date",type date}})- Set culture during conversion
Table.TransformColumnTypes(Source,{{"Amount",type number}},"en-US")Explicit culture helps interpret localized numeric text. [1][5][4]
- Keep selected columns
Table.SelectColumns(Source,{"ID","Amount"})Produces a narrower table with exactly the listed fields. [1][5][4]
- Remove unwanted column
Table.RemoveColumns(Source,{"Notes"})- Rename a column
Table.RenameColumns(Source,{{"Amount","Sales"}})
Clean text and values
- Trim a text column
Table.TransformColumns(Source,{{"Name",Text.Trim,type text}})Removes surrounding spaces from the named text field. [4][5]
- Clean nonprinting text
Table.TransformColumns(Source,{{"Name",Text.Clean,type text}})Removes control characters while retaining ordinary letters. [4][5]
- Uppercase a field
Table.TransformColumns(Source,{{"Code",Text.Upper,type text}})- Lowercase a field
Table.TransformColumns(Source,{{"Email",Text.Lower,type text}})Converts text to lowercase, not validating email syntax. [4][5]
- Replace a label
Table.ReplaceValue(Source,"N/A","Unknown",Replacer.ReplaceText,{"Status"})- Fill missing values
Table.ReplaceValue(Source,null,0,Replacer.ReplaceValue,{"Amount"})Replaces null numeric amounts; only when zero is semantically appropriate. [4][5]
- Drop duplicate IDs
Table.Distinct(Source,{"ID"})Keeps one row per ID; preserve intended order explicitly before reliance on which row survives. [4][5]
- Remove blank IDs
Table.SelectRows(Source,each [ID]<>null)- Keep positive amounts
Table.SelectRows(Source,each [Amount]>0)- Add derived column
Table.AddColumn(Source,"Net",each [Sales]-[Cost],type number)
Split, unpivot and reshape
- Split text using delimiter
Text.Split("red|green|blue","|")- Split data column in UI
- Transform → Split Column → By Delimiter
- Unpivot selected fields
- Transform → Unpivot Columns
Converts several metric columns into Attribute and Value records. [3][4]
- Unpivot other columns
- Transform → Unpivot Other Columns
Keeps selected identifier columns and turns the rest into rows. [3][4]
- Unpivot other M fields
Table.UnpivotOtherColumns(Source,{"ID"},"Metric","Value")Converts non-ID columns into paired metric and value rows. [3][4]
- Unpivot named fields
Table.Unpivot(Source,{"Jan","Feb"},"Month","Sales")Converts only listed source columns into long format. [3][4]
- Expand nested table
Table.ExpandTableColumn(Source,"Matches",{"Name"},{"CustomerName"})Retrieves selected columns from a nested table value. [3][4]
- Expand record column
Table.ExpandRecordColumn(Source,"Meta",{"City"},{"City"})- Extract first text segment
Text.BeforeDelimiter("A-B","-")
Join and group data
- Merge as new query
- Home → Merge Queries as New
Produces a separate query rather than editing a source query. [1][2]
- Left outer merge
- Join kind → Left Outer
Keeps every left-side row, adding matches from the right. [1][2]
- Left anti merge
- Join kind → Left Anti
Finds rows on the left without any corresponding right match. [1][2]
- Right anti merge
- Join kind → Right Anti
Finds rows on the right without any corresponding left match. [1][2]
- Match multiple keys
- Select paired columns in matching order
- M left join
Table.NestedJoin(Source,{"ID"},Other,{"ID"},"Matches",JoinKind.LeftOuter)Creates a nested matching-table column for each left row. [1][2]
- Group with sum
Table.Group(Source,{"City"},{{"Total",each List.Sum([Amount]),type number}})- Group count
Table.Group(Source,{"City"},{{"N",each Table.RowCount(_),Int64.Type}})- Group with average
Table.Group(Source,{"City"},{{"Average",each List.Average([Amount]),type number}})
Reserved placement, separate from reference controls. No ad network is active.
No matching entry. Try a shorter word or clear the search to see the complete sheet.
Sources
cheatsheetatlas.com/sheets/power-query/ · Updated 2026-10-20 · Power Query / M · 2026