+ Reply to Thread
Results 1 to 16 of 16

How to refresh workbook query assiociated with PowerQuery based on query name?

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    How to refresh workbook query assiociated with PowerQuery based on query name?

    Hi,

    i want to refresh specific workbook query based on its name:

    Please Login or Register  to view this content.
    but it is failing. How can i do this?
    Best,
    Jacek

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    Please try this, where Table1 is your query name


    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    Thank you,

    i will try.
    So this is not possible from query name go to connection name or i have to create string manually with this "Query - " as first word?

    Best,
    Jacek

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    The query name is just Table1

    There are many types of connection, "Query - " is to specify connection type.

    Query.png

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    What if connection name is changed?

    This will work only if you assume that connection name is a default power query name.

    Best,
    Jacek

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    I do not answer to "What if" question.
    There will be next "What if" this, "What if" that, and the question will never end.

    Provide your sample file and include all the "What if" in the completed scenario.

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    Thanks Bo_Ry,

    sorry for honesty.
    This is my full question.

    I am not using connections just queries names and figuring out if this is possible to refresh WorkbookQuery based on its name not referring to connections. Or how to refer to connection from workbook query and refresh it?
    It is not working for me because i have different connections names then "Query - " + name as PQ from default created.

    Thank you for help,
    Best,
    Jacek

  8. #8
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    Hi Guys,

    i have bad news.
    I thik that looping through Workbook.queries object has no possiblity to refer to query table and refresh.
    It is better to use for loop and loop with all listobjects and query tables...

    Best,
    Jacek

  9. #9
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    For a WorkbookConnection that is linked to a PQ query, the OLEDBCOnnection.Commandtext should be "SELECT * FROM [query name here]" so you could test that?
    Rory

  10. #10
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    Hi Rory,

    thanks.
    I have noticed it. But how could i still refresh OLEDBConnection refering to workbook query name only?
    I have to locate where this query is from listobject i think.

    Jacek

  11. #11
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    A WorkbookConnection has a Refresh method, so once you've found the right one from the Commandtext, just refresh it.

  12. #12
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    thanks Rory,

    what i have only is:

    Creator, Description, Formula and Name of workbookQuery.

    Screenshot_164.png

    i do not have oledb connection atribute.

    Best,
    Jacek

  13. #13
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    You're looping through the Queries, not the Connections.

  14. #14
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    Yes exactly.

    Please Login or Register  to view this content.
    i am looping with workbookqueries so only way to get to this is looping through workbook connections?

    Best,
    Jacek

  15. #15
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    Yes - those are the link between the query and the worksheet.

  16. #16
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: How to refresh workbook query assiociated with PowerQuery based on query name?

    Ok,

    thank you Guys for help and support.
    Best,
    Jacek

+ 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. Excel Power Query Refresh or Access Query - 2nd Query Run is faster
    By Steveapa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2020, 10:16 AM
  2. Refresh all Power Query Pivots performing only 1 Query and stops
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-04-2019, 04:49 AM
  3. Replies: 2
    Last Post: 01-24-2017, 11:22 AM
  4. Refresh all query & save. not enough time for query to complete.
    By mortphil in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-08-2015, 04:26 AM
  5. Problem with selecting range with in query table after query refresh
    By shooter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-31-2012, 11:55 AM
  6. Refresh query on saving workbook
    By Joy C in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-03-2011, 12:12 PM
  7. Query refresh in a shared workbook
    By ACurtis802 in forum Excel General
    Replies: 0
    Last Post: 04-01-2009, 05:29 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