Note
Power Query is also incorporated into Azure Data Factory, Dataflows, Power BI Report Builder and SQL Server Data Tools
- M is case sensitive
- list and record expressions are evaluated using Lazy evaluation, all other expressions are evaluated using eager evaluation
- Every value has a metadata record
- Comments:
//and/*…*/ - Escape sequence:
#(#)(
- List:
{123, true, "A"},{1..N} - Record:
[A=1, B=2, C=3] - Table:
#table({"A", "B"}, {{1, 2}, {3, 4}})- Search:
myTable{0},myTable{[A="1"]}
- Search:
- Function:
(x) => x + 1- Simplify as
each _ + 1 - prefix
@when calling a function recursively
- Simplify as
- Lookup:
[A] - Positional index:
{0} &can concatenate text, list or merge record
- The
let…inin M is similar toVAR…RETURNin DAX. Theletexpression can be nested if…then…else- Error handled by
trycan be acceseed byresult[HasError]andresult[Error][Message]. Can be used with an optionalotherwiseclause
List.GenerateList.Accumulate({1, 2, 3}, 0, (x, y) => x + y)List.Transform({1, 2, 3}, each _ * 2)
- Collect, Combine, and Transform Data Using Power Query in Power BI and Excel, 2nd Edition, by Daniil Maslyuk, Gil Raviv
- Power Query M formula language