M language (officially the Power Query Formula Language, often called M) is a functional, case-sensitive scripting language developed by Microsoft for data extraction, transformation, and loading inside Power BI, Excel Power Query, and Microsoft Power Platform — handling the “ELT” steps before data is available for DAX calculations and dashboard visualisation.

Why M Language (Power Query) Matters

M language is the data preparation engine inside Power BI and Excel. Where DAX defines calculations on already-loaded data, M is what loads the data in the first place. Every Power BI report has M code behind the scenes, often generated automatically by the Power Query GUI but increasingly written manually by power users.

For organisations on Power BI, M language is the alternative to using a separate ETL tool. M can connect to hundreds of data sources, apply transformations, and load the result into the Power BI data model — all without leaving Power BI.

How M Language (Power Query) Works

M is a functional language built around immutable data structures. Core concepts:

  • let / in expressions: M code is a series of named expressions evaluated lazily. let Source = Sql.Database(server, db), Filtered = Table.SelectRows(Source, each [country] = "USA") in Filtered
  • Steps: Each transformation is a step that produces a new table. The Power Query GUI generates these steps as you click through transformations.
  • Connectors: M includes built-in connectors for hundreds of data sources — SQL databases, REST APIs, Excel files, web pages, OData, Azure services.
  • Query folding: Where possible, M translates transformations to native SQL and pushes them to the source database, dramatically improving performance.

The Power Query GUI lets users build M scripts visually — clicking “Filter rows” or “Pivot columns” generates M code automatically. Power users edit the generated M directly for advanced scenarios.

Real-World Example

A Power BI report needs sales data from a SQL Server database, filtered to active customers only, with a calculated column for revenue category. The M code: let Source = Sql.Database("server", "db"), Sales = Source{[Schema="dbo",Item="Sales"]}[Data], Active = Table.SelectRows(Sales, each [is_active] = true), WithCategory = Table.AddColumn(Active, "RevenueCategory", each if [revenue] > 10000 then "High" else if [revenue] > 1000 then "Medium" else "Low") in WithCategory. Power BI executes this on each refresh, with most steps query-folded into native SQL.

Common M Language (Power Query) Tools and Platforms in 2026

2026 M language tool landscape:

Power BI Desktop / Service

Primary use case for M. Power Query is built into Power BI for data loading.

Excel Power Query

Same Power Query engine inside Excel. Common for finance and operations teams.

Microsoft Power Platform

Power Apps and Power Automate also use Power Query / M for data integration.

Power Query Online

Browser-based Power Query editor for Microsoft Fabric and Power BI Service.

See how Analytify replaces Power BI / M language with SQL + dbt for SaaS BI.

Learn more

Frequently Asked Questions About M Language (Power Query)

What is the difference between M language and DAX?

M language transforms and loads data into the model. DAX defines calculations on data already in the model. Power BI uses both: M to load, DAX to compute.

Is M language hard to learn?

The Power Query GUI generates most M code automatically. Reading and tweaking generated M is straightforward. Writing M from scratch for complex transformations requires functional programming concepts (lambdas, lazy evaluation, immutability) that take time to learn.

Can M language replace ETL tools?

For Power BI-centric stacks, often yes. M can connect to most data sources, apply transformations, and load to Power BI. For multi-tool stacks where data needs to land in a warehouse for multiple consumers, dedicated ETL tools (ETL) or dbt are better fits.

What is query folding?

M’s ability to translate transformations into the source database’s native query language (typically SQL) and push them to the source. Query folding means transformations execute on the database server, not on the Power BI machine — much faster for large data.

Is M language portable outside Microsoft tools?

Generally no. M is a Microsoft language tied to Power Query. Migrating off Power BI requires rewriting M transformations in the new tool’s language (SQL, dbt, or another ETL tool).

Should I learn M or stick to the Power Query GUI?

Start with the GUI. Most transformations can be built visually. Learn M when you need advanced features the GUI does not expose: complex conditional logic, custom functions, dynamic source selection, or custom error handling.

Related Concepts

← Back to the Analytify glossary