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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
jgsudderth
New Member

Help with Dynamic File Path without using parameters

I am importing an access database.  My current M code is the following:  

 

 

let
    Source = Access.Database(File.Contents("C:\Users\John\Company Finance Dropbox\Accounting and Finance\Access Databases\Daily Sales Snapshot v6.0.accdb"), [CreateNavigationProperties=true]),

 

 

The problem is when another person tries to use this file, the references break because of the hard coded file Reference to "John".  Everything else will be the exact same.  I have read 25+ articles on how to make this a reference and figured it out yesterday but can't remember which of the million options I tried made it work.  

 

I'd like instead of "John" to be the current username of whoever is working on the report.  It may be Jack, Jill, etc. but everything else will be the same.  I can't remember how to pull the current file path.  There was a query I wrote (maybe it was a function) that gave me that filepath, and then I could replace the hardcoded part of the filepath with a reference to that query.

 

Thanks for your help!

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@jgsudderth ok, check this post to get the user name, which you can use to replace the user from the path:

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@jgsudderth ok, check this post to get the user name, which you can use to replace the user from the path:

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@jgsudderth maybe create a parameter with the name value and replace the name with the parameter, so anytime the parameter value is changed, it will update the path.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

The problem is I don't know if it will be Jack, Jill, Jack 2, etc.  I'd like to future-proof this as much as possible so pulling the current user via a file path function and then inserting that would allow me to not know EVERY username that could ever use the file.  Unfortunately laptops and desktops all create new "usernames" as part of that dropbox file reference.  

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors