Power Query Dynamic File Path & Name

DaytoData

New Member
Joined
Aug 22, 2017
Messages
3
I have a dynamic table called "NewFilePath" with a header "FILE_LOCATION" which I have imported into PowerQuery using the following M which works:
Code:
let
    Source = Excel.CurrentWorkbook(){[Name="NewFilePath"]}[Content],
    FileCriteria = Record.Field(Source{0},"FILE_LOCATION")
in
    FileCriteria

What I want to do is use the FILE_LOCATION value in instead of C:\Users\cmw1s\Documents\TEST_DATA_SOURCE.xlsx

Code:
let
    Source = Excel.Workbook(File.Contents([B]"C:\Users\cmw1s\Documents\TEST_DATA_SOURCE.xlsx"[/B]), null, true),
    TEST_DATA_Table = Source{[Item="TEST_DATA",Kind="Table"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(TEST_DATA_Table,{{"DATE", type date}, {"DATA_VALUE", Int64.Type}})
in
    #"Changed Type"

I've tried the following, but received the error "Formula.Firewall: Query 'TEST_DATA' (step 'Changed Type') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination."

Code:
let
    NFP = NewFilePath,
    Source = Excel.Workbook(File.Contents(NFP), null, true),
    TEST_DATA_Table = Source{[Item="TEST_DATA",Kind="Table"]}[Data],
    #"Changed Type" = Table.TransformColumnTypes(TEST_DATA_Table,{{"DATE", type date}, {"DATA_VALUE", Int64.Type}})
in
    #"Changed Type"

Any help would be greatly appreciated!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
The easiest way is to adjust the privacy options:
Data tab - Get Data - Query Options - Privacy (under Current Workbook) - check "Ignore the Privacy Levels....(etc)"
 
Upvote 0
Hi Marcel

I have had this problem as well but I'm concerned about the caveat when selecting this setting about it possible exposing sensitive data to unauthorized people.

Can you put my mind to rest on this?


Thanks
Michael
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

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