This quick tour describes creating Power Query M formula language queries.
Note
M is a case-sensitive language.
Create a query with the Power Query editor
To create an advanced query, you use the Power Query advanced editor. A mashup query is composed of variables, expressions, and values encapsulated by a let expression. A variable can contain spaces by using the # identifier with the name in quotes as in #"Variable name".
A let expression follows this structure:
Power Query M
let
Variablename = expression,
#"Variable name" = expression2
in
Variablename
To create an M query in the advanced editor, you follow this basic process:
Create a series of query formula steps that start with the let statement. Each step is defined by a step variable name. An M variable can include spaces by using the # character, such as #"Step Name". A formula step can be a custom formula. Also note that the Power Query formula language is case sensitive.
Each query formula step builds upon a previous step by referring to a step by its variable name.
Output a query formula step using the in statement. Generally, the last query step is used as the in final data set result.
Let's assume you created the following transform in the Power Query editor. This query converts product names to the appropriate case, in this instance, to all initial capitalization.
To begin with, you have a table that looks like this:
OrderID
CustomerID
Item
Price
1
1
fishing rod
100
2
1
1 lb. worms
5
3
2
fishing net
25
And, you want to capitalize the first letter in each word in the Item column to produce the following table:
OrderID
CustomerID
Item
Price
1
1
Fishing Rod
100
2
1
1 Lb. Worms
5
3
2
Fishing Net
25
The M formula steps to project the original table into the results table look like this in the Power Query advanced editor:
Here's the code you can paste into the Power Query advanced editor:
This module introduces Power Query in Microsoft Excel, a powerful data connection, cleaning, and shaping technology that is a core part of the Microsoft modern analytics suite of business intelligence tools.
Demonstrate the business value and product capabilities of Microsoft Power Platform, such as Power Apps, data connections with Dataverse, and Power Automate.