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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Excel, OneDrive and Sharepoint relative path

I am using OneDrive and Excel as part of Office 365. In the link below, Ken Puhls writes about using the Cell function to get the path of the open excel file to determine where to get other files (a relative path).

 

https://www.excelguru.ca/blog/2014/11/26/building-a-parameter-table-for-power-query/ 

 

I use this technique and it works great. However, sometimes my team members open the file directly from the sharepoint site and the link returned is 

sharepoint.PNG

 

In theory, I could detect the value (https) and then pull the files from the relative path off of the Sharepoint site. Has anyone tried this approach? I would imagine that the queries could be much slower as they would be working over the network as opposed to the local OneDrive. 

 

Thank you,

Mike

 

 

3 REPLIES 3
KNP
Super User
Super User

Hi Mike,

 

I have had similar issues. I chose to get around it by using VBA and mapping the sharepoint site as a network drive prior to any query execution but that may not be an option for you. 

 

I think your idea about checking the path before (or not before - see link below) executing the code should work relatively easily. 

If you had both blocks of code in the same query, one for sharepoint and one for local path you could then just execute conditionally based on the path. 

This is the best post I've seen about conditional code branching in Power Query (https://community.powerbi.com/t5/Community-Blog/Conditional-Code-Branching-in-Power-BI-Query-if-then...), may be useful.

 

I don't have time to test this right now but I'm curious to hear your results and whether the performance is significantly different.

 

Regards,

Kim

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

I worked a lot with both techniques (using reading relative path of file as well as reading from the sharepoint). I've encountered never a problem with both of them. However I never tried to read all files from a relative path of the sharepoint. Are you using sharepoint online? But I think there should be no problem using this technique.

 

Jimmy

Anonymous
Not applicable

Hi @Jimmy801 ,

 

I am using Sharepoint online. I tried writing code that would dynamically handle either situation about a year ago. I never did get it right and so I built everying using OneDrive. I was wondering if anyone else attempted this approach.


Thank you,

Mike

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors