Excel Data Model File Path Change

Copper Contributor

My boss created an Excel data model before I joined the company. He created the data model and queried the data from files within his personal drive. Now that I am here, he wants me to have access to these files and has moved them into a shared folder. The thing is, all of the queries now have the wrong file path. Is the only way to fix this to manually update the file path within the Source step of the power query editor? If there is an easier way, please let me know!

3 Replies

@CalebF22 

That's to update manually. For future updates use paths as parameters, at least folder part of it.

Could you elaborate further on the future updates?

@CalebF22 

If you have queries like

let
    Source = Excel.Workbook(File.Contents("C:\Test\testA.xlsx"), null, true),
    Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data]
in
    Sheet

you may create parameter

image.png

and change queries to

let
    Source = Excel.Workbook(File.Contents( pFilePath & "testA.xlsx"), null, true),
    Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data]
in
    Sheet

Next the only you need is to edit parameter at one place. In general you may use parameters for full filenames; or keep them in grid, call by another query and combine in main queries, etc. Depends on your needs.