This tutorial will help you understand more about the M code found inside the Advanced Editor.

Some people prefer to call it “M formula language” or “M function.” You can use it to filter and combine your data from multiple data sources.

How To Access Power BI’s M Language

To access the M code, select a query. For this example, we’ll click the Sales query.

After that, click Advanced Editor to open the editing window.

power bi m language

In the Advanced Editor window, you can view or modify the entire code that appears for the selected query.

power bi m language

The code looks complicated, but you don’t need to learn how to write the said codes. All that matters is your understanding of how the code works and what it does.

In a nutshell, these codes are records of the transformations or actions that were done for the selected query.

Understanding M Code Inside The Advanced Editor

The first thing you can see inside the M code is the source. In this part, you can see the location where the system has retrieved the data.

power bi m language

As you can also see, the system automatically identifies the data type for the Order Date, Ship Date, etc.

Next, you can see the records of the transformations that were done to the data such as Rename Column, Removed Column, Duplicated Column, and many more.

power bi m language

You can see a lot of codes here because of the different data transformations. However, you don’t really need to write these codes because you can make it work just by clicking or selecting something from the ribbon.

Let’s say you want to change something. You want to rename Order Date to Ordering Date. You can do it inside the Advanced Editor.

If you change the column name to Ordering Date, you can see the particular step inserted in all the prior steps of the code. Once you click Done, the corresponding column in the query is also updated.

Now that you have an initial idea of how things work in the M code, I’ll show you an example where you can get an error.

#powerbi #developer

Beginners’ Guide To The M Code In Power BI
2.40 GEEK