Created by: Paul Pitcher
Creation Date: Aug 16, 2025
Updated Date: Oct 14, 2025
M Language
(also called: M, Power Query M, M formula language, M Formulas, M code, Power Query M formula language, M Query, Mashup Query )
- see the Power Query wiki page for more information
-invented by Microsoft.
Click here
for more information from Microsoft.
-M at its most simplest can be described as "getting data". it allows us to Transform the data. Note: DAX also helps us to transform our data.
-M is primarily used for data mashup, which involves filtering, combining, and transforming data from various sources. It allows users to create complex queries that can automate data preparation tasks.
- The "M formula language" gets its name because it is used to "Mashup data" hence the M. in fact it is a "mashup language".
- M is a "functional language" similar to the F# programming language.
- M is embedded within the "Power Query Editor" a tool that is included in Power BI. Users can perform data transformations through a graphical user interface (GUI). The actions taken in the interface generate M code in the background, which can be viewed and edited.
- Once you are in the "Power Query" window you can view the M code by going to the "home" tab and then finding the "query" section and then clicking on the "advanced editor" button. This will open a new window called "Advanced Editor". TIP: the "Advanced Editor" window combines all of the code from each of the steps that you see in the "APPLIED STEPS" on the right hand side.
- The M language includes nearly 1000 unique functions that can be utilized for various data manipulation tasks, such as filtering, sorting, and merging tables.
Here is the list of these functions.
Some of these functions are not available in the "Power Query" GUI.
Tip: if you click on the blue "?" in the upper right corner you will be taken to the Microsoft page where you can view a list of the Power Query M functions.
Tip: in the upper right corner you can click on "Display options" to modify the editor window so that the code is easier to read.
-M code typically consists of two main blocks: The "let" block, where variables are defined, and the "in" block, which specifies the output of the query.
Q: How does "Power Query" interact with the M Language?
A: "Power Query" is a window that you can open with power BI where you can modify the data coming into Power BI. "Power Query" is the GUI interface that creates the M code in the background. Clicking on the "Advanced Editor" button with in "Power Query" will open the "Advanced Editor" window so that you can view or modify the M code. Simply put the "Advanced Editor" window will let you see the M code that "Power Query" is creating as you interact with "Power Query" GUI interface.
Q: is M-code simular DAX code?
A: No, M code and DAX (Data Analysis Expressions) are not the same. They are two distinct languages used in Power BI, each serving different purposes and operating in separate contexts.
Q: If i take the PL-300 test will i be questioned about M ?
A: no
Q: In power bi why does M-code need to be translated into DAX when working with direct query?
A: im not sure where this question came from. Im not sure it is correct. I need to learn more about this topic. For example I don't know if if M code is converted to DAX code. When I did a google search I didn't find anything on this topic.
A: One google answer gave me this. M and DAX are not dependent upon each other and follow totally different structures and logics, and have different underlying codes. M and DAX cannot be used simultaneously since the M language is used in "Power Query Editor" while DAX is mostly used in the Data View (? Where is the data view? ).
====
Q: how do I add comments to my M code?
Overview: In the C language you can add comments in 2 ways
1. Single-line Comment
// your text here
2. Multi-line (also called a "Block") Comment
/*
Your text here
more text here
Text on multiple lines
*/
You can also use multiple line comment for just one line
/* your text here */
TIP: You can also use these methods of adding comments to the M language.
====