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

- 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 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.
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.
Navigate to the Data tab in Excel and select 'Get Data' or 'Launch Power Query Editor' to view your current queries.
Click on the specific step in the 'Applied Steps' pane or open the 'Advanced Editor' from the Home tab to modify your formula.
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 ...

Use a Unicode Expression
If doubling quotes makes your code difficult to read, you can use the Unicode representation for a quotation mark instead.
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. 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. Open Your Spreadsheet: Launch WPS Spreadsheet and click 'Open' to load your existing .xlsx or .csv files seamlessly.
- 3. Analyze Your Data: Use the Data tab and built-in formula library to process, filter, and analyze your data without formatting issues.

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.




