Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
McSarah
Helper I
Helper I

Formula.Firewall - failed dynamic Excel connection when using list parameters in connection string.

Hi guys, I've searched and found many threads that seem closely related to my issue, but none exactly addressed my problem. This actually seems simpler than most of the problems I've found, so hopefully many people know what I should do.

 

I am trying to build a dynamic connection string to an excel workbook in PowerQuery, where the file name in the connection string is supplied with a parameter: 

 

Source = Excel.Workbook(File.Contents("<MyFolderPath>" & Param1), null, true)

 

This works great if the parameter passes a hard coded string value, but fails as soon as I change it to use a Query/ List as the source. Then, I get this standard error message:

 

Formula.Firewall: Query 'Query1' (step 'Table') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.

 

This problem occurs even when the parameterized query contains nothing but the data connector and the excel sheet selector. I've stripped the M down to the simplest possible code; this is the entire thing:

 

let
      Source = Excel.Workbook(File.Contents("<MyFolderPath>" & Param1), null, true),
      Table = Source{[Item="DataSource",Kind="Sheet"]}[Data]
in
      Table

 

For this reason, solutions like the one in this excellent blog post (https://www.excelguru.ca/blog/2015/03/11/power-query-errors-please-rebuild-this-data-combination/) don't seem to apply; I'm only pulling a single data source so there can't be any permissions conflict, and I'm not doing any tranformations that might present challenges for query folding. The data source Permissions setting for all my data sources for this workbook is set to "Public", so even if there were more than one data sourcein this code, permissions conflict shouldn't be the source of this problem.

 

Here is my complete data flow to create the list I use as the source for the file name parameter.

let
      Source = Folder.Files("<MyFolderPath>"),
      #"Removed Columns" = Table.RemoveColumns(Source,{"Content", "Extension", "Date accessed", "Date modified", "Attributes", "Date created"}),
     #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each Text.StartsWith([Name], "<stuff i need to filter on>")),
     List = #"Filtered Rows"[Name]
in
     List

 

Next, I go to Manage Parameters and configure my parameter to use Suggested Values: "Query" and Query: "List" (to get the list resulting from the code above). Then I use the parameter in my connection string as above. That's it.

 

I can't think of anything else to check besides the things I've done -- radically simplifying the initial query, checking the permissions. What have I missed?

 

 

 

1 REPLY 1
v-alq-msft
Community Support
Community Support

Hi, @McSarah 

 

I'd like to suggest you try to modify the privay level as 'Ignore the Privacy Levels and potentially improve performance'(File=>Options=>CurrentFile=>Privacy). Or you may combine all your codes in one query to see if it works.

 

For further information, please refer to the similar thread .

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors