+ Reply to Thread
Results 1 to 7 of 7

A button that modifies the SQL query [Power Query]

  1. #1
    Registered User
    Join Date
    05-20-2024
    Location
    Poland
    MS-Off Ver
    365
    Posts
    4

    A button that modifies the SQL query [Power Query]

    Hi, I need to create a button, a formula, a macro that modifies an SQL query in Power Query.

    Query calculate date from day to day. Each time I have to enter the query and change the end date (marked in red).
    Is it possible in Excel to enter the date in a cell and then enter a button that will update the query?
    makro.jpg

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,301

    Re: A button that modifies the SQL query [Power Query]

    You can create a parameter table to use in PQ:

    https://support.microsoft.com/en-us/...0-b205a69e0f33

    "M is for Data Monkey" by Puls and Escobar covers it in detail, too.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    05-20-2024
    Location
    Poland
    MS-Off Ver
    365
    Posts
    4

    Re: A button that modifies the SQL query [Power Query]

    Thank you for your suggestion.
    I tried doing this by adding a parameter and referencing it in the query, but I got an error.
    error.png

    Full query code below
    query.png

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,009

    Re: A button that modifies the SQL query [Power Query]

    You need to concatenate it into the SQL:

    ,'" & EndDate & "'))#

    etc
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Registered User
    Join Date
    05-20-2024
    Location
    Poland
    MS-Off Ver
    365
    Posts
    4

    Re: A button that modifies the SQL query [Power Query]

    Back to the topic. I need help
    I still have some syntax error.
    error.jpg

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,009

    Re: A button that modifies the SQL query [Power Query]

    If EndDate is a number, not text, you'll need to wrap it in Text.From to be able to concatenate it:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-20-2024
    Location
    Poland
    MS-Off Ver
    365
    Posts
    4

    Re: A button that modifies the SQL query [Power Query]

    Thank you very much.
    Now I can change a parameter in 20 queries with one click

+ 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. [SOLVED] Power Query: Merge Query using Reference Query
    By barrywhitelaw in forum Excel General
    Replies: 9
    Last Post: 03-06-2024, 09:59 AM
  2. [SOLVED] Power Query: Add a new query to an existing Query that already has multiple queries
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-06-2023, 04:33 PM
  3. [SOLVED] [Power Query] How to filter 0 from two columns in power query editor in one step?
    By daliye in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-16-2023, 09:44 PM
  4. Replies: 1
    Last Post: 07-14-2023, 10:15 AM
  5. [SOLVED] Power Query - excel formula translation into Power Query
    By afgi in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 02-19-2020, 03:38 AM
  6. Replies: 4
    Last Post: 02-17-2020, 06:03 AM
  7. 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

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