Cover of M Is for (Data) Monkey, a guide to the Power Query M language for Excel and Power BI by Ken Puls and Miguel Escobar

Published

2015

Power BI and DAX ✨ New

M Is for (Data) Monkey

A Guide to the M Language in Power Query for Excel and Power BI

Master the M language and build reliable, reusable data transformation pipelines in Power Query β€” without guessing your way through the formula bar.

Power Query's M language sits behind every query you build in Excel and Power BI, but most users never learn to write it directly. M Is for (Data) Monkey by Ken Puls and Miguel Escobar changes that. It walks you through M from first principles, showing you how to connect to data sources, clean messy inputs, reshape tables, and automate repetitive transformation work β€” all in plain, practitioner-focused language backed by real examples.

About this book

Every time you click through Power Query's interface, M code is being written on your behalf. That works fine until the interface can't do what you need β€” and then you're stuck. M Is for (Data) Monkey closes that gap by teaching you to read, write, and modify M directly, so the query editor does exactly what you intend instead of approximately what you clicked.

Ken Puls and Miguel Escobar are two of the most widely trusted voices in the Power Query community. In this book, they translate years of hands-on consulting work into a structured, example-driven introduction to the M language. You don't need a programming background. You need a willingness to look past the ribbon and understand what's actually happening in your queries.

The book moves at a deliberate pace. Early chapters cover the fundamentals: how M evaluates expressions, how data types work, and how the query editor generates code you can then modify. Later chapters tackle practical transformation challenges β€” combining files from a folder, handling errors gracefully, building reusable custom functions, and working with nested tables and lists. Each concept is grounded in the kind of data problems analysts face every day.

  • Connect to files, folders, databases, and web sources using M
  • Understand how the M query evaluation model works step by step
  • Clean and reshape tables without depending on the GUI for every change
  • Combine and append queries across multiple sources reliably
  • Write custom functions that encapsulate logic you can reuse across workbooks
  • Handle errors and nulls so your pipelines don't silently break
  • Work with lists, records, and tables as first-class M values

Whether you're an Excel analyst moving toward Power BI or a Power BI developer who has been avoiding the Advanced Editor, this book gives you the vocabulary and confidence to work with M as a real language rather than a black box. The skills you build here carry directly into every Power BI report and Excel workbook you build from this point forward.

🎯 What you'll learn

  • Read and modify M code generated by the Power Query interface
  • Understand how M evaluates expressions and handles data types step by step
  • Connect to diverse data sources including files, folders, databases, and web endpoints
  • Reshape and clean messy tables using M functions rather than manual GUI steps
  • Write custom functions that encapsulate reusable transformation logic
  • Combine and append data from multiple sources into a single, reliable query
  • Handle errors and null values so your pipelines fail loudly instead of silently
  • Work confidently with M's core data structures: lists, records, and tables

πŸ‘€ Who is this book for?

  • Excel analysts who use Power Query regularly but have never written M by hand
  • Power BI developers who avoid the Advanced Editor and want to stop treating M as a black box
  • Business intelligence professionals who need to build robust, maintainable data pipelines without writing SQL or Python
  • Data analysts tasked with automating repetitive data-cleaning work across multiple files or sources
  • Consultants and report builders who want reusable query logic they can carry from project to project

Table of contents

  1. 01

    Introduction to Power Query and M

    Get oriented to the Power Query environment, understand where M fits in the Excel and Power BI ecosystem, and load your first dataset using the query editor.

  2. 02

    The M Language Basics

    Learn how M evaluates expressions, how let and in blocks work, and how each step in the Applied Steps pane corresponds to a line of M code.

  3. 03

    Data Types and Values

    Explore M's core value types β€” text, number, date, logical, null β€” and understand why getting types right prevents silent errors downstream.

  4. 04

    Connecting to Data Sources

    Connect to flat files, Excel workbooks, folders of files, databases, and web sources, and learn how M's source functions differ by connector type.

  5. 05

    Transforming and Shaping Tables

    Apply filters, rename columns, change types, pivot and unpivot data, and merge or append queries using M functions you can read and edit directly.

  6. 06

    Lists, Records, and Tables

    Work with M's three compound data structures as first-class values, and learn how to navigate and transform nested data that the GUI struggles to reach.

  7. 07

    Writing Custom Functions

    Build parameterized M functions that encapsulate repeated transformation logic, then invoke them across multiple queries or workbook files.

  8. 08

    Error Handling and Robustness

    Use try, otherwise, and Table.AddColumn patterns to catch and manage errors so your queries surface problems explicitly rather than returning wrong results silently.

  9. 09

    Real-World Transformation Patterns

    Work through end-to-end examples drawn from common analyst workflows β€” combining monthly exports, normalizing inconsistent source formats, and automating file-folder ingestion.

Frequently asked questions

Do I need programming experience to read this book?

No. The book assumes you have used Power Query's interface in Excel or Power BI but have no prior experience writing M code. Programming concepts are introduced from scratch in plain language.

Does this book cover DAX or Power BI report building?

No. The book focuses entirely on the M language and Power Query data transformation. DAX and report-layer topics are out of scope, though the skills here complement DAX work directly.

Is the content still relevant given how much Power BI has changed since 2015?

The M language itself has remained stable, and the core concepts taught here still apply. Some screenshots and connector interfaces may look different in current versions of Power BI Desktop or Excel, but the query logic and function patterns are accurate.

Which product do I need β€” Excel, Power BI Desktop, or both?

The M language and Power Query engine are shared across both products. Most examples work in either environment, so you can follow along with whichever tool you have access to.

Are sample files or companion downloads included?

Check the publisher or authors' official pages for any companion files associated with the book. No download links are bundled directly in this listing.

You might also like

πŸ“¬ Weekly Newsletter

Stay ahead of the curve

Get the best programming tutorials, data analytics tips, and tool reviews delivered to your inbox every week.

No spam. Unsubscribe anytime.