0% found this document useful (0 votes)
3 views2 pages

Power Query M Language Guide

This document is a beginner's guide to the Power Query M language, outlining its basic structure and common functions for data manipulation. It includes examples for importing tables, filtering rows, removing and renaming columns, changing data types, and sorting tables. Additionally, it provides a beginner exercise for filtering and renaming a column in an Excel table.

Uploaded by

vce.engineeers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Power Query M Language Guide

This document is a beginner's guide to the Power Query M language, outlining its basic structure and common functions for data manipulation. It includes examples for importing tables, filtering rows, removing and renaming columns, changing data types, and sorting tables. Additionally, it provides a beginner exercise for filtering and renaming a column in an Excel table.

Uploaded by

vce.engineeers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Power Query M Language – Beginner Guide

🧾 Power Query M Language – Cheat Sheet (Beginner)

🔹 Basic Structure

let
StepName = SomeFunction(Source),
NextStep = AnotherFunction(StepName)
in
NextStep

🔹 Common Functions

| Purpose | Function | Example |


|-----------------|-----------------------------------|--------------------------------------------------------------|
| Import Table | Excel.CurrentWorkbook() | Excel.CurrentWorkbook()
{[Name="SalesData"]}[Content] |
| Filter Rows | Table.SelectRows | Table.SelectRows(Source, each [Amount] > 1000)
|
| Remove Columns | Table.RemoveColumns | Table.RemoveColumns(Source,
{"Column1", "Column2"}) |
| Rename Columns | Table.RenameColumns | Table.RenameColumns(Source,
{{"OldName", "NewName"}}) |
| Change Type | Table.TransformColumnTypes | Table.TransformColumnTypes(Source,
{{"Amount", type number}})|
| Sort Table | Table.Sort | Table.Sort(Source, {{"Date", Order.Ascending}})
|
| Add Column | Table.AddColumn | Table.AddColumn(Source, "NewCol", each
[Amount]*2) |
| Merge Queries | Table.NestedJoin | Used via UI or advanced manually
|

🔹 Data Types in M

- type text – text/string


- type number – numeric
- type date, type datetime
- type logical – true/false

Beginner Exercise: Filtering and Renaming


Goal:
Load a table from your Excel file and filter out rows where the "Amount" is less than 1000. Then
rename the column "Amount" to "Sales Value".

Steps:

1. Create a simple table in Excel:


| Name | Amount |
|--------|--------|
| Alice | 500 |
| Bob | 1500 |
| Carol | 1200 |

2. Give this table a name, e.g., SalesData (select table → right-click → Table Name in top-left).

3. Go to Excel → Data tab → Get Data → From Other Sources → Blank Query.

4. In the Power Query Editor, open Advanced Editor and paste this:

let
Source = Excel.CurrentWorkbook(){[Name="SalesData"]}[Content],
FilteredRows = Table.SelectRows(Source, each [Amount] >= 1000),
RenamedColumns = Table.RenameColumns(FilteredRows, {{"Amount", "Sales Value"}})
in
RenamedColumns

5. Click Close & Load to load the result back into Excel.

You might also like