Forum Discussion
Parameters for Source and Environment in Power Query
Hi, PRV
Based on the information you provided, the root cause of the problem is a compatibility limitation of parameterized connections with DirectQuery.
Power Query needs to get a list of databases (metadata) in the Snowflake.Databases() step first, and dynamically concatenating ENVIRONMENT &_CONSUMPTION causes Power BI to fail to precompile static SQL queries in DirectQuery mode. Metadata operations, such as listing tables/views, often force a switch to Import mode. The parameters SF_ROLE and ENVIRONMENT are passed dynamically during the join process, while DirectQuery requires that the data source connection parameters must be fully determined during the initial join step and cannot be dynamically calculated through subsequent steps. When you also expand the list of tables in the schema, Power Query generates an operation (implicit metadata query) that contains a Value.NativeQuery by default, which breaks the linear execution chain of DirectQuery.
You can try bypassing metadata enumerations and hard-coding database and schema names directly, controlling only the roles and environments via parameters:
let
Source = Snowflake.Databases(
"pistor.west-europe.azure.snowflakecomputing.com",
ENVIRONMENT & "_CONSUMPTION", // Advance the database name to the join layer
[Role = SF_ROLE]
),
LOGISTIK_Schema = Source{[Name = "LOGISTIK", Kind = "Schema"]}[Data]
in
LOGISTIK_Schema
Or enable native query mode to force the use of Native Query to pass SQL directly in Power Query. To create a blank query, enter the following code:
let
Source = Value.NativeQuery(
Snowflake.Databases(..., [Role = SF_ROLE]),
"SELECT * FROM " & ENVIRONMENT & "_CONSUMPTION. LOGISTIK. YourTableName",
null, [EnableFolding = true]
)
in
Source
Make sure that all subsequent steps don't add actions that can't be collapsed, such as custom columns
In Power BI Desktop, right-click the query → properties → check Don't allow connection mode changes. Once you've tried the workaround, you'll also need to check if the mode is DirectQuery.
You can check the following links:
DirectQuery in Power BI - Power BI | Microsoft Learn
Connect to Snowflake with Power BI - Power BI | Microsoft Learn
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- PRV1 year agoFrequent Visitor
Thanks for the explanation and the given options, but the problem is not solved yet.