Forum Discussion

AndreasNederman's avatar
AndreasNederman
New Member
10 days ago

SQL Power Query in Power Bi

Hi Anyone,

In the new September update is there still a good way to write and edit SQL in Power Query.

Otherwise I must say the update is gone break so many things and make Power Bi more or less useless.

6 Replies

  • Yes. In the September update, you can still write/edit SQL, but the new Power Query experience has some limitations around query inputs and the native-query workflow. Microsoft currently recommends switching back to the Legacy Power Query experience if the new UI is getting in the way.

    Try this:

    File → Options and settings → Options → Preview features → uncheck “New Power Query experience”

    You don't need to restart Power BI Desktop.

    For SQL editing, use:

    Get Data → SQL Server → Advanced options → SQL statement

    And for Power Query/M code, use:

    Transform data → View → Advanced Editor.

    So if the September UI is breaking your existing workflow, Legacy Power Query is currently the practical workaround.

  • v-achippa's avatar
    v-achippa
    Icon for Community Support rankCommunity Support

    Hi AndreasNederman​,

    Thank you for reaching out to Microsoft Fabric Community.

    Yes, you can still write and edit SQL queries in Power Query. Go to Get Data --> SQL Server --> Advanced options --> SQL statement and enter your native SQL query.

    If the SQL statement option is not available in the new Power Query experience, go to File --> Options and settings --> Options --> Preview features and clear New Power Query experience, and use the existing Power Query editor.

    Thanks and regards,
    Anjan Kumar Chippa

  • @AndreasNederman

    Yes, you can still edit SQL in Power Query, though how it works depends on your connector and how the query was built in the first place.

    If you're dealing with issues from the September update, could you share the exact error or behavior you're seeing? There might be a workaround depending on your setup.

    I completely understand the frustration—it's super annoying when updates mess up workflows that used to work fine.

    If your workflow is breaking due to new SQL in power query, you may opt to switch back to legacy power query experience .

    https://learn.microsoft.com/en-us/power-bi/transform-model/power-query-new-experience-limitations

    If this helps, ✓ Mark as Kudos | Help Other

  • v-achippa's avatar
    v-achippa
    Icon for Community Support rankCommunity Support

    Hi  AndreasNederman​,

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution I have provided for the issue worked? or let us know if you need any further assistance.

    Thanks and regards,
    Anjan Kumar Chippa

  • v-achippa's avatar
    v-achippa
    Icon for Community Support rankCommunity Support

    Hi  AndreasNederman​,

    We wanted to kindly follow up to check if the solution I have provided for the issue worked? or let us know if you need any further assistance.

    Thanks and regards,
    Anjan Kumar Chippa

  • Hi AndreasNederman​,

    Switching back to the legacy experience works, but there is also a way to keep your SQL fully editable that doesn't depend on which Power Query UI you have: put the SQL in M with Value.NativeQuery. You then edit it in the Advanced Editor like any other code, and it survives UI changes.

    A minimal example against SQL Server, with a parameter instead of a hard-coded date:

    let
        Source = Sql.Database("myserver.database.windows.net", "SalesDB"),
        Result = Value.NativeQuery(
            Source,
            "SELECT CustomerID, SUM(Amount) AS Amount
             FROM dbo.Sales
             WHERE OrderDate >= @StartDate
             GROUP BY CustomerID",
            [StartDate = #date(2026, 1, 1)],
            [EnableFolding = true]
        )
    in
        Result

    Two details make this better than the SQL statement box in the connector dialog:

    parameters record  -> values are passed as real SQL parameters,
                          no string concatenation, easy to drive
                          from Power BI parameters
    EnableFolding=true -> later steps (filters, column removal)
                          can still fold into your SQL

    If several queries share long SQL, I would also keep each statement in its own text parameter (Manage Parameters > New, type Text) and reference it in Value.NativeQuery. Then editing the SQL is just editing the parameter value.

    Microsoft documents the folding behavior in query folding on native queries.

    So my overall approach would be:

    SQL inside Value.NativeQuery in the Advanced Editor
    -> parameters record instead of concatenated strings
    -> EnableFolding = true so later steps still fold
    -> legacy Power Query UI only as a temporary fallback

    That keeps your SQL workflow stable regardless of future Power Query UI updates.

    AI-assisted drafting: AI was used to help structure and phrase this response. I reviewed and validated the technical content before posting.