How to Fix Power Query “Formula.Firewall: Query references other queries”

The Power Query error Formula.Firewall: Query 'QueryName' (step 'StepName') references other queries or steps, so it may not directly access a data source occurs when Power Query blocks an operation to prevent unauthorized data leakage between different sources. This is not a data corruption issue or an M-code syntax error. It is an intentional barrier enforced by the Power Query Mashup Engine when a query combines external data calls with steps or parameters evaluated in another query without matching privacy levels.

Fast Fix

In Excel, open Data > Get Data > Query Options. Under Current Workbook, select Privacy, choose Ignore the Privacy levels and potentially improve performance, and click OK. If organization compliance policies prohibit disabling privacy checks, restructure your M-code: extract all external data in separate staging queries first, then merge or reference those queries downstream.


Diagnostic Snapshot

PropertyDetails
Error MessageFormula.Firewall: Query '[X]' (step '[Y]') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.
Root CauseMashup Engine blocks data transmission across security boundaries where private values might be leaked to an external source.
Primary TriggerPassing a dynamic value (from an Excel cell, local table, or separate query) directly into an external function like Web.Contents or Sql.Database.
Escalation PointCompany security policies enforced via Microsoft Purview or group policy preventing changes to Data Privacy settings.

Why the Mashup Engine Blocks the Query

Power Query uses privacy levels (Public, Organizational, Private) to keep sensitive data safe. If your workbook contains a local table marked Private (such as internal employee IDs) and you run a web query marked Public, Power Query must decide how to evaluate them.

If a query takes an ID from the Private table and dynamically appends it into an API URL call inside a single step, the Mashup Engine assumes the private ID could be transmitted to an unverified third-party web server. To protect against accidental exfiltration, the firewall stops execution immediately.

This error typically happens when:

  1. A parameter or lookup value from Query A is fed into a source connection function (Sql.Database, Web.Contents, OData.Feed) inside Query B.
  2. Multiple data sources with conflicting or unassigned privacy levels are joined in a single step without intermediate buffering.

Step-by-Step Resolution Paths

Path 1: Align or Bypass Privacy Levels (Workbook Level)

If you are working with internal, trusted data sources on your local machine, adjusting the privacy setting is the fastest solution.

  1. Open Excel and navigate to the Data tab.
  2. Click Get Data > Query Options.
  3. In the left pane, navigate to Current Workbook > Privacy.
  4. Select Ignore the Privacy levels and potentially improve performance.
  5. Click OK, then go to Data > Refresh All.
[Query Options]
  └── Current Workbook
        └── Privacy
              └── (o) Ignore the Privacy levels and potentially improve performance

Note: If this report will be published to Power BI Service or refreshed by other enterprise users whose desktop clients enforce privacy levels, this setting will not fix the issue for them. In that case, use Path 2.

For deeper issues where privacy prompts keep reappearing despite adjusting these settings, see Troubleshooting “Information is needed regarding data privacy” Refresh Loops.


Path 2: Re-architect the Query into a Staging Pattern

To keep privacy protections active while preventing firewall errors, isolate the external source request from the data transformation step.

The Broken Pattern (Fails Firewall):
Query 1 reads a date parameter from an Excel sheet. Query 2 connects to a database and filters rows directly inside the source navigation step using the parameter from Query 1.

The Correct Pattern (Passes Firewall):

  1. Query A (Raw Source): Connects to the external source without referencing any other query. It pulls the unfiltered table or uses static source navigation.
  2. Query B (Parameters): Reads your local Excel cell, parameter, or lookup list.
  3. Query C (Transformation/Merge): References Query A and Query B, performing the filter or merge after both datasets have been independently loaded into the Mashup Engine’s memory.

By separating source acquisition from row filtering, the engine does not transmit local query values across the external boundary during connection negotiation.


Path 3: Use M-Code Buffering for Dynamic External Calls

When using dynamic URLs with Web.Contents, passing variable query parameters into the base URL string triggers the firewall. Rewrite the step using the standard Query option in Web.Contents combined with Table.Buffer or Binary.Buffer.

Problematic Code:

// Fails firewall when ApiKey comes from another query
let
    Key = ApiKeyQuery,
    Source = Json.Document(Web.Contents("<https://api.example.com/data?key=>" & Key))
in
    Source

Compliant Code:

let
    Key = ApiKeyQuery,
    Source = Json.Document(
        Web.Contents(
            "<https://api.example.com>",
            [
                RelativePath = "data",
                Query = [key = Key]
            ]
        )
    )
in
    Source

Separating the root URL from the query string parameters informs the firewall that the base endpoint is static, allowing the mashup engine to validate privacy compliance.


When Enterprise Policies Block Privacy Changes

If the options under Current Workbook > Privacy are grayed out or revert upon restarting Excel, your device is managed by Group Policy or Microsoft Intune requiring strict evaluation.

In these environments:

  1. Go to Data > Get Data > Data Source Settings.
  2. Select each data source individually and click Edit Permissions.
  3. Set the Privacy Level for all internal sources to Organizational.
  4. Ensure no internal databases or local files are left as None.

If mismatches persist between local execution and tenant-wide rules, refer to Troubleshooting “Privacy Level” Mismatches between Workbook and Cloud.