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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Power Query Editor Dynamic SharePoint Links

Hello,
I currently have several files that link to a SharePoint to obtain their data, as shown in the screenshot the first line has the SharePoint link, and the other marked lines are the actual file path. (for data compliance I had to mark them so they are not viewable)

Spartan_0-1664198849436.png

 

I need to change the file every update from a test environment to the production environment, meaning that the SharePoint changes too. I can manually alter the source links when that happens, but I want to make it dynamic using a variable.


Is it possible to define a variable in the Power Query Editor to have that variable in each file source and equal a link, and I can change the link once for the new environment and it will automatically change it in all of the files I am sourcing in Power BI?

 

I hope this is clear what I am trying to accomplish, and I appreciate any support here! 

1 ACCEPTED SOLUTION

Hi @Anonymous & @serpiva64  - I would encourage you to simply the Power Query by introducing Table.SelectRows filter after the Source step using Text.Contains for the Folder Name filter.  This will make it easy to manage the parameters passed from outside the query.  The M advanced editor will look more like this.

let
  Source = SharePoint.Files(#"SharePoint Site", [ApiVersion = 15]),
  Folder = Table.SelectRows(Source, each Text.Contains( [FolderPath] , #"SharePoint Folder") ),
  File = Table.SelectRows(File, each [FolderPath] = #"SharePoint File"),
  #"Open Excel" = Excel.Workbook( File{0}[Content] )
in
  #"Open Excel"


This should make it possible to pass parameters to update the SharePoint Site and Folder and 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

I dont quite understand.

I have copied the advanced editor structure below, where the FILENAME will remain the same, but the SHAREPOINT_FILE_PATH changes. It has worked with the main SharePoint Link which is set as SharePoint Link.
But I do not know how to format the SharePoint File Path sections so I dont get error messages.

 

let
Source = SharePoint.Files(#"SharePoint Link", [ApiVersion = 15]),
#"FILENAME xlsx_SHAREPOINT_FILE_PATH" = Source{[Name="FILENAME xlsx_SHAREPOINT_FILE_PATH"]}[Content],
#"Imported Excel Workbook" = Excel.Workbook(#"FILENAME xlsx_SHAREPOINT_FILE_PATH"),
#"Incident Records_Sheet" = #"Imported Excel Workbook"{[Item="Incident Records",Kind="Sheet"]}[Data]

Hi @Anonymous & @serpiva64  - I would encourage you to simply the Power Query by introducing Table.SelectRows filter after the Source step using Text.Contains for the Folder Name filter.  This will make it easy to manage the parameters passed from outside the query.  The M advanced editor will look more like this.

let
  Source = SharePoint.Files(#"SharePoint Site", [ApiVersion = 15]),
  Folder = Table.SelectRows(Source, each Text.Contains( [FolderPath] , #"SharePoint Folder") ),
  File = Table.SelectRows(File, each [FolderPath] = #"SharePoint File"),
  #"Open Excel" = Excel.Workbook( File{0}[Content] )
in
  #"Open Excel"


This should make it possible to pass parameters to update the SharePoint Site and Folder and 

serpiva64
Solution Sage
Solution Sage

Hi, 

You can try creating a new parameter

serpiva64_0-1664201071514.png

serpiva64_1-1664201116074.png

 

then you use  it in your selection

= Table.SelectRows(Source, each ([Folder Path] = "https://XXXXXXXX.sharepoint.com/sites/Ambienteditest/Documenti condivisi/"&Parameter1&"/"))

Then you can change your parameter in Desktop, in Power Query Editor and also in the Service

If this post is useful to help you to solve your issue consider giving the post a thumbs up 

 and accepting it as a solution !

 

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.