Power Query’s quote style controls how text values are enclosed in quotes during exports or transformations, ensuring data integrity when saving to CSV, Excel, or other formats. Choosing the right quote style prevents misinterpretation of commas, tabs, or line breaks within text fields. No additional tools or installations are needed—this is a built-in setting in Power Query Editor.

What You'll Need

  • Microsoft Excel 2016 or later with Power Query enabled
  • Power BI Desktop (if using Power BI)
  • A data source already loaded into Power Query Editor

Step-by-Step

  1. Open Excel or Power BI Desktop and load your data into Power Query Editor. This is done by selecting Data > Get Data and choosing your source (Excel, CSV, database, etc.), then clicking Load & Transform.
  2. In the Power Query Editor window, locate the ribbon at the top. Click the Home tab if it isn’t already selected.
  3. Find the Advanced Editor button on the far right of the ribbon. Do not click it yet—this is for editing M code directly. Instead, look for the Export group, which includes buttons like Close & Load and Save As.
  4. Click the small downward arrow under the Close & Load button to reveal a menu. Select Close & Load To... to open the Import Data dialog box.
  5. In the Import Data dialog, choose Only Create Connection and check the box labeled Add this data to the Data Model if needed, then click Load. This returns you to the Power Query Editor.
  6. Now go to the Home tab again and click the Advanced Editor button. You’ll see the M code for your query. Look for the line that ends with Destination = Csv.Document(...) or Excel.Workbook(...). If you’re exporting to CSV, the quote style is controlled by parameters in the Csv.Document or Csv.Write function.
  7. To change quote style, modify the Csv.Document or Csv.Write function. For example, change Csv.Document(Source, [Delimiter=",", Encoding=1252]) to Csv.Document(Source, [Delimiter=",", Encoding=1252, QuoteStyle=QuoteStyle.None]). The quote style can be set to QuoteStyle.None, QuoteStyle.Csv, or QuoteStyle.None.
  8. Click Done to apply the changes. The preview window will update to reflect the new quote style.
  9. Test your output by clicking Close & Load and opening the exported file in Notepad or a text editor to verify that quotes are applied (or not) as expected.
  10. If you’re using Excel.CurrentWorkbook() or writing back to Excel, quote style is managed differently—use the Table.ToRows() function and wrap strings manually if needed. For Excel output, quote style is determined by Excel’s default CSV behavior and cannot be controlled directly in Power Query.
  11. For non-CSV exports like JSON or XML, quote style is handled internally and cannot be modified; only CSV and text exports allow quote style adjustments.

Common Mistakes

  • Trying to set quote style in Excel export (not supported)—Power Query only allows quote style control for CSV and text outputs, not Excel files.
  • Using QuoteStyle.Csv when your data contains no commas, leading to unnecessary quote wrapping that bloats file size.
  • Editing the M code without understanding syntax, causing query errors—always copy the original line before modifying it.
  • Assuming quote style applies to all output types—even if you set it correctly for CSV, it won’t affect JSON, XML, or database exports.
  • Confusing quote style with delimiter style—changing the delimiter (e.g., from comma to tab) doesn’t affect whether quotes are used around values.

Tips

  • Use QuoteStyle.None for clean data exports where fields contain no delimiters or line breaks—this reduces file size and improves readability.
  • Use QuoteStyle.Csv when your text contains commas, quotes, or line breaks—this ensures Excel or other programs parse the data correctly.
  • Test your output in a plain text editor (like Notepad++) before opening in Excel to verify quote behavior.
  • When working with international data, ensure encoding is set to UTF-8 (Encoding=65001) to avoid character corruption, especially when combining quote styles.
  • Save your query as a template after configuring quote style correctly—this avoids reconfiguring it for similar data sources later.
  • If you’re automating exports via Power Automate or PowerShell, always specify quote style explicitly in the M code to prevent default behavior from overriding your intent.

Troubleshooting

  • Query fails after editing Advanced Editor: Check for missing commas, unmatched brackets, or typos in function names. Revert to the original code and reapply changes slowly.
  • Quotes still appear even after setting QuoteStyle.None: Confirm you’re not using a function like Text.Combine that adds quotes manually. Also ensure your source data doesn’t already contain quotes.
  • Exported file looks corrupted in Excel: Open the CSV in Notepad. If fields are misaligned, your quote style may be mismatched with your delimiter. Try switching between QuoteStyle.Csv and QuoteStyle.None.
  • No Advanced Editor option visible: This happens if you’re in Query View instead of Power Query Editor. Click Edit Query from the Data tab to re-enter the editor.
  • Quote style setting ignored on save: You may be using a non-Csv export method. Only Csv.Document and Csv.Write support quote style parameters—other functions like Json.Document do not.

Frequently Asked Questions

Can I change quote style when exporting to Excel?

No. Excel files (.xlsx) do not use quote styles because they store data in structured binary format, not as plain text. Quote style only applies to CSV and text exports.

What’s the difference between QuoteStyle.Csv and QuoteStyle.None?

QuoteStyle.Csv wraps all text values in double quotes, even if they contain no special characters, to ensure compatibility. QuoteStyle.None never adds quotes, which saves space but risks parsing errors if text contains commas or line breaks.

Why does my CSV open with quotes in Excel but not in Notepad?

Excel automatically detects and removes quotes during import for CSV files, even if they’re present. Notepad shows the raw file content. Use Notepad to verify if quotes were actually written.

Can I apply quote style to multiple queries at once?

No. Each query must be edited individually in the Advanced Editor. You can copy and paste the modified M code between queries if they use the same structure.

Does quote style affect database exports like SQL Server or PostgreSQL?

No. Power Query uses different drivers and protocols for databases that handle quoting internally. Quote style is only relevant for flat-file exports like CSV and TXT.

Is QuoteStyle case-sensitive in M code?

Yes. Use QuoteStyle.Csv and QuoteStyle.None exactly as written. Typing quotestyle.none will cause an error.