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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.