Relative file path for large external data flat files #Parameter

andydtaylor

Active Member
Joined
Feb 15, 2007
Messages
360
Office Version
  1. 2016
Hi,

I need to reference several multi_GB external text files. However I want my work to be easily ported to another user's computer. So I thought I'd use a parametised query to read current path from a worksheet table generated using a vba macro.

However I seem to be hitting a restriction of some kind because I get the message:

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

What is the right way to do this?


1. Generate parameter
Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Current Directory", type text}}),
    Current_Directory = #"Changed Type"{0}[Current Directory]
in
    Current_Directory

2. Use parameter
Code:
let

    Current_Directory = Get_Current_Directory,

    Source = Csv.Document(Web.Contents(Current_Directory & "\" & "SupplierInvoices_20160101_20161231.csv"),[Delimiter="|", Columns=23, Encoding=1200, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])
in
    #"Promoted Headers"


Thanks,


Andy
 
Last edited:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Fixed my own problem LOL

Basically I needed to use "Text.Combine" to concatenate the parameter and string describing the source file

Code:
let

    Current_Directory = Get_Current_Directory,
    Current_Directory_Combined = Text.Combine({Current_Directory,"\SupplierInvoices_20160101_20161231.csv"}, ""), 

    Source = Csv.Document(Web.Contents(Current_Directory_Combined),[Delimiter="|", Columns=23, Encoding=1200, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true])
in
    #"Promoted Headers"
 
Last edited:
Upvote 0
BTW it was also necessary to change Query options>Privacy within query editor to "Combine data according to each file's Privacy Level settings"
 
Upvote 0

Forum statistics

Threads
1,217,414
Messages
6,136,492
Members
450,016
Latest member
murarj

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top