+ Reply to Thread
Results 1 to 12 of 12

Power Query - How to refresh queries?

  1. #1
    Registered User
    Join Date
    12-06-2010
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Wink Power Query - How to refresh queries?

    Hello,

    I have not been here in long time, I miss you all! Well, I've learned something new and excited to use it but I'm stuck.

    Here is what I was trying to do. At work, I will receive a report with 3 columns - A, B and C (order number, delivery number and Reason code) The column for reason code is blank and that's what we need to fill out. It's about 200 rows at least.

    Here what I do, I have a file with 3 columns A, B and C same as the report but with C filled with reason code. I use the Power Query, create connection with these two tables and get the reason code to show on the Report (Just like the Vlookup).

    Now, my question is, for next month when I receive the report, do I have to create the connection again? If not, how do I use the query to click refresh?

    I appreciate your help. Have a nice day and great weekend.

  2. #2
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Power Query - How to refresh queries?

    If the new report has the same name and is in the same location, then you can click Refresh All on the Data tab in the ribbon.
    If the name of the report and/or the location you'll could use named ranges to make the connection flexible.
    So you'll never need to make the connection again, maybe just adjust it.
    Cheers!
    Tsjallie




    --------
    If your problem is solved, pls mark the thread SOLVED (see Thread Tools in the menu above). Thank you!

    If you think design is an expensive waste of time, try doing without ...

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Power Query - How to refresh queries?

    I am not familiar with Power Query, but I do something similar with MS-Query. I use MS-Query to establish the connection to the database. MS-Query has a query editor similar to MS-Access but except for very simple queries, it is more of a hindrance than a help. In my case, I work with Oracle databases. I write and debug the code there and then copy it into the SQL window for MS-Query.

    If MS-Query can display it graphically, then I can pass parameters to it either at run-time though a dialog box or through cells on the spreadsheet. The cells could have dynamic formulas like TODAY()-1 and TODAY()-91 or whatever.

    If MS-Query cannot display the SQL graphically, then I have a method using Excel Tables and a short piece of VB code to re-write the query prior to execution. This not only allows me to pass parameters, but I have done things like switch tables, rewrite where clauses and just about anything else as long as I stay in the same data connection (database).

    If you are interested, I can walk you through the setup.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  4. #4
    Registered User
    Join Date
    12-06-2010
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Power Query - How to refresh queries?

    Hello dflak,

    Thank you very much for the offer. However, I don't VB code and MS Query at all. Otherwise, I would love to learn from you. Thanks again!

  5. #5
    Registered User
    Join Date
    12-06-2010
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Power Query - How to refresh queries?

    Quote Originally Posted by Tsjallie View Post
    If the new report has the same name and is in the same location, then you can click Refresh All on the Data tab in the ribbon.
    If the name of the report and/or the location you'll could use named ranges to make the connection flexible.
    So you'll never need to make the connection again, maybe just adjust it.
    Reason.xlsxReport.xlsx

    Hi Tsjallie,

    I've attached two files here. One is the Reason file that we keep track everyday with reason code, the other one is the report we received from manager. Now, I've completed it and successfully applied the reason code.

    And yes, the report will be in the same location but with different name because next month, the report name might be ReportMarch something like that. And the Reason file will have ReasonMarch. In this situation, I think we have to re create the query. Am I right?

    Thanks for your help! I really appreciate it.

  6. #6
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Power Query - How to refresh queries?

    Here's what I've done to make your query flexible.

    In Report.xlsx I added a sheet Parameters in which I added the FileLocation (B1) and FileName (B2).
    Then created a named range "FileLocation" for B1 and "FileName" for B2.
    Change the path in B1 to yr needs (don't forget the / at the end).
    Change the filename in B2 to yr needs.

    Then I added a queryfunction (fnGetNamedRange) for reading named ranges.
    And finally I adjusted the query Table1 to use the queryfunction to get the file location and file name.
    The source step in the query now looks like this
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    You won't need to change the query anymore when the file name or file location changes. Just change the parameters.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    12-06-2010
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Power Query - How to refresh queries?

    Hello,

    I did reply to you about this Parameter you set, but I don't know why it didn't show. Anyway, I just want to let you know how much I appreciate your help. However, I've never used parameters and query function. It's a little confusing to me.

    Thanks again.

  8. #8
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Power Query - How to refresh queries?

    Apart from the help you can get on this forum, here's a nice tutorial for beginners

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Power Query - How to refresh queries?

    Hi ypurcaro,

    Could you change your profile and show what version of Excel you are using? Excel 2003 doesn't have Power Query.

    I think what is suggested above, without using a parameter, is to click the gear icon next to Source and change it to your current month file. It should then do the same steps but with the new file.

    https://support.office.com/en-us/art...d-6a4921380ca9
    Last edited by MarvinP; 02-11-2019 at 05:30 PM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  10. #10
    Forum Expert Tsjallie's Avatar
    Join Date
    09-15-2012
    Location
    NL
    MS-Off Ver
    2010, 2013, 2016
    Posts
    2,077

    Re: Power Query - How to refresh queries?

    I assumed Excel 2003 can use the add-on, but then again that's from a previous life

    BTW, the file name and location can be set in the sheet Parameters. Nothing needs to be changed in the Query itself.

  11. #11
    Registered User
    Join Date
    12-06-2010
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Power Query - How to refresh queries?

    Quote Originally Posted by MarvinP View Post
    Hi ypurcaro,

    Could you change your profile and show what version of Excel you are using? Excel 2003 doesn't have Power Query.

    I think what is suggested above, without using a parameter, is to click the gear icon next to Source and change it to your current month file. It should then do the same steps but with the new file.

    https://support.office.com/en-us/art...d-6a4921380ca9
    My Excel version is 2010.

  12. #12
    Registered User
    Join Date
    12-06-2010
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: Power Query - How to refresh queries?

    Thanks for the tutorial link, it's very helpful!

+ 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. Code to change Power Query source and refresh
    By kersplash in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-23-2021, 07:35 AM
  2. Editing Workbook Queries (Power Query)
    By dizjackson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-04-2019, 03:11 AM
  3. Power Query shows as external data connection and can't refresh online
    By fuadramsey in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-26-2018, 06:04 PM
  4. Sub-Forum for Excel Power Tools (Power Query, Power Pivot & Power BI)
    By chullan88 in forum Suggestions for Improvement
    Replies: 10
    Last Post: 06-28-2018, 02:25 PM
  5. Does My VBA Code To Refresh CSV Power Query Connections Need To Change for MySQL Queries?
    By beaglesBuddy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2017, 02:57 PM
  6. code to refresh power query not working ..
    By Hassan1977 in forum Excel General
    Replies: 0
    Last Post: 08-31-2016, 12:31 PM

Tags for this Thread

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