+ Reply to Thread
Results 1 to 14 of 14

PowerQuery - Set up Query Parameters to avoid hardcoded paths

  1. #1
    Registered User
    Join Date
    06-09-2015
    Location
    Barcelona
    MS-Off Ver
    Windows 10
    Posts
    11

    Angry PowerQuery - Set up Query Parameters to avoid hardcoded paths

    Hi All -

    my name is Simone and I am trying to fix this issue.

    my query path is

    = Excel.Workbook(File.Contents("C:\Users\Simone\Box Sync\4_International\GM Entity 4049 Database.xlsx"), null, true)

    and I want to make the Simone path dynamic.. right now I m the only one that can refresh the file. I would like also other people doing it.

    How should I approach the problem? I spent the last 3 hours reading and tyring but no success.

    Thanks a lot in advance.
    Simone

  2. #2
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    What do you mean by "right now I m the only one that can refresh the file"?

    Do the other users have Power Query activated?

    The source file needs to be able to be seen by the users trying to refresh the query.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,933

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    Place the file at a location that all users are able to access (maybe a network location) and change the hard-coded path name to reflect this.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    06-09-2015
    Location
    Barcelona
    MS-Off Ver
    Windows 10
    Posts
    11

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    the file is shared on box.. so everyone is opening box should be able to refresh it. so the path is not recognized.

    i.e. on his pc Marco should have = Excel.Workbook(File.Contents("C:\Users\Marco\Box Sync\4_International\GM Entity 4049 Database.xlsx"), null, true)

  5. #5
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    But that would mean each user needs to maintain a copy of the up-to-date source file on their computer.

    Store it in a network location or common drive location and point to that.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,933

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    Yes, but not everybody is a user called Marco!

    You need the file to be located somewhere that is not in a local file path (e.g. a network drive). The C drive is local to the machine you are working on.

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    It will depend on your folder structure.

    Where would the file containing query will be placed? Could it be anywhere in the local drive? Or is there specific designated location within Box Sync?

    If latter, I'd probably do something like...
    Lets say the workbook with the query is stored in the same folder as the file being queried.
    1. Add Parameter sheet to the workbook with query.
    2. Add in any cell of the sheet, following formula. This will give folder path to where the file is saved.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    3. Select the cell and make it named range with name "vPath".
    4. In query editor add following line after "let".
    Please Login or Register  to view this content.
    5. Replace "Source =" line with...
    Please Login or Register  to view this content.
    Let me know how it works out.

    Edit: If it gives error message about security level. Set both the workbook and queried workbook to Organizational.
    Last edited by CK76; 10-24-2018 at 10:33 AM.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  8. #8
    Registered User
    Join Date
    06-09-2015
    Location
    Barcelona
    MS-Off Ver
    Windows 10
    Posts
    11

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    I am storing the file in a box folder (cloud). Then i synchronized the box folder on my pc... and I build my file. I was reading that there is a way to make the name dynamic
    read this...



    techcommunity.microsoft.com/t5/Excel/Power-Query-Source-from-Relative-Paths/td-p/206150


    but I have 0 idea on how to apply on my case.

  9. #9
    Registered User
    Join Date
    06-09-2015
    Location
    Barcelona
    MS-Off Ver
    Windows 10
    Posts
    11

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    i ll try. it sounds what I want to do.

  10. #10
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    techcommunity.microsoft.com/t5/Excel/Power-Query-Source-from-Relative-Paths/td-p/206150
    Yes, that's the same method as my post, and standard method for dynamic folder path (to a point). Queried file must have consistent path relative to workbook with query.

  11. #11
    Registered User
    Join Date
    06-09-2015
    Location
    Barcelona
    MS-Off Ver
    Windows 10
    Posts
    11

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    at the end I used this one youtube.com/watch?v=6qUUxAsSomU . Now I have the issue of

    Formula.Firewall: Query 'f_4000000-6999999' (step 'Merged Queries') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.


    I want to die

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,933

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    It's not worth dying for ...

    Everything referenced in the file in question needs to be available in that one central universally accessible network place. Otherwise you will get errors like this.

  13. #13
    Registered User
    Join Date
    06-09-2015
    Location
    Barcelona
    MS-Off Ver
    Windows 10
    Posts
    11

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    I agree... but my architecture is to have 1 source and 1 mapping shared for all the file. People are crazy and the modify the mapping..

  14. #14
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: PowerQuery - Set up Query Parameters to avoid hardcoded paths

    Formula firewall, is often result of how you build your query dependency.

    If the initial query is used within another query, try combining two into single query in "M".

    Have a read of link below for more detail on how to avoid formula firewall.
    https://blog.crossjoin.co.uk/2017/06...irewall-error/

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Avoid PowerQuery refresh from deleting empty columns
    By Barslund in forum Excel General
    Replies: 10
    Last Post: 01-10-2018, 04:19 AM
  2. Replies: 0
    Last Post: 05-18-2017, 06:58 PM
  3. Web Query w/parameters
    By sarnone in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-23-2009, 02:01 PM
  4. Query parameters
    By Lac in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-13-2006, 08:10 AM
  5. Replies: 2
    Last Post: 03-08-2006, 09:15 AM
  6. [SOLVED] Query Parameters
    By Texas_Toast in forum Excel General
    Replies: 0
    Last Post: 01-11-2006, 11:20 AM
  7. User-changeable paths into Excel - avoid hard coding
    By gearoi in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-31-2005, 11:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1