{"id":108,"date":"2026-02-24T10:08:59","date_gmt":"2026-02-24T10:08:59","guid":{"rendered":"https:\/\/gigz.pk\/excel\/?post_type=lesson&#038;p=108"},"modified":"2026-03-10T04:28:38","modified_gmt":"2026-03-10T04:28:38","slug":"m-language-basics","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/excel\/lesson\/m-language-basics\/","title":{"rendered":"M Language Basics"},"content":{"rendered":"\n<p><strong>M Language<\/strong> (also called <strong>Power Query Formula Language<\/strong>) is the scripting language used behind the scenes in Power Query to transform and manipulate data.<\/p>\n\n\n\n<p>Every step you perform in Power Query automatically generates M code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is M Language?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Functional programming language<\/li>\n\n\n\n<li>Case-sensitive<\/li>\n\n\n\n<li>Used in Power Query<\/li>\n\n\n\n<li>Automates data transformation steps<\/li>\n\n\n\n<li>Works step-by-step<\/li>\n<\/ul>\n\n\n\n<p>You can view M code by going to:<\/p>\n\n\n\n<p><strong>Power Query Editor \u2192 Home \u2192 Advanced Editor<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Basic Structure of M Code<\/h2>\n\n\n\n<p>Most queries follow this structure:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">let<br>    Source = Excel.CurrentWorkbook(){[Name=\"Sales\"]}[Content],<br>    ChangedType = Table.TransformColumnTypes(Source, {{\"Amount\", type number}})<br>in<br>    ChangedType<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Explanation:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>let<\/strong> \u2192 Defines steps<\/li>\n\n\n\n<li>Each line = One transformation step<\/li>\n\n\n\n<li><strong>in<\/strong> \u2192 Returns final result<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Important Concepts in M Language<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"> Steps<\/h3>\n\n\n\n<p>Each transformation creates a named step.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">FilteredRows = Table.SelectRows(Source, each [Sales] &gt; 50000)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"> Case Sensitivity<\/h3>\n\n\n\n<p>M is case-sensitive:<\/p>\n\n\n\n<p>Correct:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Table.SelectRows<\/pre>\n\n\n\n<p>Incorrect:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">table.selectrows<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"> Data Types<\/h3>\n\n\n\n<p>Common data types:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>type text<\/li>\n\n\n\n<li>type number<\/li>\n\n\n\n<li>type date<\/li>\n\n\n\n<li>type datetime<\/li>\n\n\n\n<li>type logical<\/li>\n<\/ul>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Table.TransformColumnTypes(Source, {{\"Date\", type date}})<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"> Filtering Data<\/h3>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Table.SelectRows(Source, each [Department] = \"IT\")<\/pre>\n\n\n\n<p>Filters only IT department.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"> Adding Custom Column<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">Table.AddColumn(Source, \"Profit\", each [Sales] - [Cost])<\/pre>\n\n\n\n<p>Creates a new column called Profit.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"> Removing Columns<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">Table.RemoveColumns(Source, {\"UnnecessaryColumn\"})<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Comments in M<\/h2>\n\n\n\n<p>Use double slash:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ This is a comment<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Why Learn M Language?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Customize advanced transformations<\/li>\n\n\n\n<li>Automate complex logic<\/li>\n\n\n\n<li>Modify auto-generated steps<\/li>\n\n\n\n<li>Improve data modeling skills<\/li>\n\n\n\n<li>Essential for Power BI and advanced Excel users<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">M Language vs Excel Formulas<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>M Language<\/th><th>Excel Formula<\/th><\/tr><\/thead><tbody><tr><td>Works in Power Query<\/td><td>Works in worksheet<\/td><\/tr><tr><td>Applied before loading data<\/td><td>Applied after data loads<\/td><\/tr><tr><td>Step-based transformations<\/td><td>Cell-based calculations<\/td><\/tr><tr><td>Handles large data efficiently<\/td><td>Slower with large datasets<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Keep step names clear<\/li>\n\n\n\n<li>Avoid unnecessary steps<\/li>\n\n\n\n<li>Use Advanced Editor carefully<\/li>\n\n\n\n<li>Test transformations step-by-step<\/li>\n\n\n\n<li>Learn basic functions first<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>M Language is the foundation of Power Query. Understanding its basics helps you control and customize data transformations efficiently, making your Excel data preparation more powerful and professional.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/excel\/\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">Excel Automation &#038; Power Tools (EAPT) > Introduction to Power Query > M Language Basics<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1773116999681\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n","protected":false},"menu_order":66,"template":"","class_list":["post-108","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>M Language Basics - Learn Excel the Right Way.<\/title>\n<meta name=\"description\" content=\"Learn M Language in Power Query for Excel. Automate data transformations, create custom steps, and master advanced data prep\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/excel\/lesson\/m-language-basics\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"M Language Basics - Learn Excel the Right Way.\" \/>\n<meta property=\"og:description\" content=\"Learn M Language in Power Query for Excel. Automate data transformations, create custom steps, and master advanced data prep\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/excel\/lesson\/m-language-basics\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn Excel the Right Way.\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-10T04:28:38+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/excel\\\/lesson\\\/m-language-basics\\\/\",\"url\":\"https:\\\/\\\/gigz.pk\\\/excel\\\/lesson\\\/m-language-basics\\\/\",\"name\":\"M Language Basics - Learn Excel the Right Way.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/excel\\\/#website\"},\"datePublished\":\"2026-02-24T10:08:59+00:00\",\"dateModified\":\"2026-03-10T04:28:38+00:00\",\"description\":\"Learn M Language in Power Query for Excel. Automate data transformations, create custom steps, and master advanced data prep\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/excel\\\/lesson\\\/m-language-basics\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/excel\\\/lesson\\\/m-language-basics\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/excel\\\/lesson\\\/m-language-basics\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/excel\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Excel Automation & Power Tools (EAPT) > Introduction to Power Query > M Language Basics\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/excel\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/excel\\\/\",\"name\":\"Learn Excel the Right Way.\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/excel\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"M Language Basics - Learn Excel the Right Way.","description":"Learn M Language in Power Query for Excel. Automate data transformations, create custom steps, and master advanced data prep","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/gigz.pk\/excel\/lesson\/m-language-basics\/","og_locale":"en_US","og_type":"article","og_title":"M Language Basics - Learn Excel the Right Way.","og_description":"Learn M Language in Power Query for Excel. Automate data transformations, create custom steps, and master advanced data prep","og_url":"https:\/\/gigz.pk\/excel\/lesson\/m-language-basics\/","og_site_name":"Learn Excel the Right Way.","article_modified_time":"2026-03-10T04:28:38+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/excel\/lesson\/m-language-basics\/","url":"https:\/\/gigz.pk\/excel\/lesson\/m-language-basics\/","name":"M Language Basics - Learn Excel the Right Way.","isPartOf":{"@id":"https:\/\/gigz.pk\/excel\/#website"},"datePublished":"2026-02-24T10:08:59+00:00","dateModified":"2026-03-10T04:28:38+00:00","description":"Learn M Language in Power Query for Excel. Automate data transformations, create custom steps, and master advanced data prep","breadcrumb":{"@id":"https:\/\/gigz.pk\/excel\/lesson\/m-language-basics\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/excel\/lesson\/m-language-basics\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/excel\/lesson\/m-language-basics\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/excel\/"},{"@type":"ListItem","position":2,"name":"Excel Automation & Power Tools (EAPT) > Introduction to Power Query > M Language Basics"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/excel\/#website","url":"https:\/\/gigz.pk\/excel\/","name":"Learn Excel the Right Way.","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/excel\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/excel\/wp-json\/wp\/v2\/lesson\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/excel\/wp-json\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/excel\/wp-json\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/excel\/wp-json\/wp\/v2\/media?parent=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}