Power Query Problems

How to Escape Quotation Marks in Excel Power Query

Tauseeq MagsiTauseeq Magsi Oct 23, 2026 869 views

Question details

The user needs to know the correct syntax for escaping quotation marks within text strings in Excel Power Query (M language) formulas.

How to Escape Quotation Marks in Excel Power Query
Product
Excel Power Query
Device & OS
not provided
Scenario
Writing or editing formulas in the Power Query Editor that require matching, comparing, or outputting text strings containing literal quotation marks.
Observed behavior
Standard single quotation marks cause syntax errors when nested inside text strings, as the formula misinterprets them as the end of the text string.
Before you start

Before modifying your M code, ensure you have verified the exact text string you are trying to match to avoid logic errors in your query results.

Solution 1Recommended

Escape by Doubling the Quotation Marks

The most common and direct method to escape a quotation mark in Power Query is to type it twice consecutively.

In the M language, text strings are always enclosed in double quotes. When you need to include an actual double quote character within that string, you must double it so the query engine recognizes it as a literal character rather than the end of the string.

1
Open Power Query Editor

Navigate to the Data tab in Excel and select 'Get Data' or 'Launch Power Query Editor' to view your current queries.

2
Locate the formula

Click on the specific step in the 'Applied Steps' pane or open the 'Advanced Editor' from the Home tab to modify your formula.

3
Double the quotation marks

When typing the string, use two consecutive quotation marks ("") for every literal quotation mark. For example, to check if a column equals "value", write the statement as: if [Column] = """value""" then ...

Escape by Doubling the Quotation Marks
Syntax Check: In the example """value""", the outermost quotes define the text string, while the inner paired quotes represent the escaped quotation marks around the word 'value'.
Free Microsoft Office alternative

Edit Spreadsheets Seamlessly with WPS Office

While Power Query provides specific data manipulation tools in Microsoft Excel, WPS Office offers a lightweight, highly compatible, and free alternative for your everyday spreadsheet editing, data analysis, and reporting needs.

  1. 1. Download and Install WPS Office: Visit the official WPS website, download the free installation package, and follow the on-screen instructions to set it up on your device.
  2. 2. Open Your Spreadsheet: Launch WPS Spreadsheet and click 'Open' to load your existing .xlsx or .csv files seamlessly.
  3. 3. Analyze Your Data: Use the Data tab and built-in formula library to process, filter, and analyze your data without formatting issues.
Fully compatible with Microsoft Excel (.xlsx, .xls, .csv) formats to ensure your data displays correctly.Comprehensive data analysis tools, including PivotTables and a vast library of advanced formulas.Familiar user interface for a zero-learning-curve transition from Microsoft Office.Free and lightweight, avoiding heavy system resource usage during complex data tasks.
microsoft office alternative - wps office

Frequently Asked Questions

Why do standard quotation marks cause errors in Power Query formulas?

In Power Query (M language), a standard quotation mark is used to define the beginning and end of a text string. If you include an unescaped quotation mark inside the string, the system mistakenly assumes the string has ended prematurely, resulting in a syntax error.

Can I use single quotes instead of double quotes to define text in Power Query?

No, Power Query requires double quotes (") to enclose text strings. Single quotes (') are strictly used for different purposes, such as enclosing identifier names (like custom column names) that contain spaces or special characters.

How do I escape other special characters in Power Query?

Other special characters can be escaped using their specific Unicode values or predefined M language escape sequences with the #() syntax. For instance, #(tab) is used for a tab character, and #(cr,lf) is used for a carriage return and line feed.