Power QueryExercises

Identifiers, quoted names, escapes and comments

Read and write names, text escapes and comments without syntax errors.

~8 min read · beginner · Module 16: M language basics

By Tahir Nas · Examples run in our simulator · Updated

Before this: M basics: let, records and lists

Most M syntax errors in hand-edited queries come from three small things: names with spaces, text containing quotes, and case. This lesson covers each, plus comments, which make a query explain itself.

Quoted identifiers

A plain name starts with a letter or underscore and contains letters, digits, underscores and dots (that's why Table.SelectRows is one name). Anything else, such as a space, a bracket or a currency sign, needs the #"…" form. Both forms refer to the same name:

/* Monthly totals for the travel budget */
let
    #"Budget (€)" = 1200,
    // Spent so far this year
    #"Spent YTD" = 950,
    Remaining = #"Budget (€)" - #"Spent YTD"
in
    Remaining

Result

250

Output produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M.

// comments run to the end of the line; /* … */ comments can span lines.

Case sensitivity

Names are case-sensitive, and the error message is the same as for a typo:

let
    Source = #table({"Qty"}, {{2}}),
    Total = List.Sum(source[Qty])
in
    Total

Result: an error

Expression.Error: The name 'source' wasn't recognized. Make sure it's spelled correctly.

Output produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M.

The name 'source' wasn't recognized. The step is called Source.

Escapes inside text

You wantWriteNotes
A double quote""Two quotes inside the text
A tab#(tab)Also #(lf) line feed, #(cr) carriage return
A character by code#(00E9)Four hex digits: é
A literal #(#(#)(Rarely needed
#table({"Text", "Length"}, {
    {"Say ""hi""", Text.Length("Say ""hi""")},
    {"a#(tab)b", Text.Length("a#(tab)b")},
    {"caf#(00E9)", Text.Length("caf#(00E9)")}
})

Result

TextLength
Say "hi"8
a b3
café4

Output produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M.

Field and column names

Inside [...] field access, names with spaces don't need #"…": [Order Date] works. In records you build yourself, quote awkward names the same way: [#"Unit Price" = 4].

Where to find this in Excel

There's no button for this. In Excel you write it in the Power Query editor's Advanced Editor (View > Advanced Editor, also on the Home tab), which shows the whole query as M.

Paths are for the Power Query editor in Excel for Microsoft 365, checked against Microsoft's documentation on 8 November 2026: Use Power Query to transform data (the Power Query editor) (Microsoft Learn).

Common mistakes

  • Writing a step name with spaces without the #"…" wrapper.
  • Using a single quote or a backslash to escape a double quote inside text.
  • Changing the case of a step name in one place and not the others.

Excel, Power BI and the simulator

  • Excel and Power BI Desktop: renaming a step in the Applied Steps pane writes the #"…" form for you when needed and updates references.
  • In Excel and Power BI Desktop, a step description added with right-click → Properties is saved as a // comment above that step in the M code.
  • The simulator supports // and /* */ comments, quoted identifiers and the #( ) escapes shown here.

Next step

Check that the ideas in this lesson stuck. The quiz explains every answer, including the wrong ones.

Take the M language basics quiz