Native Runtime Parameter Preservation for Value.NativeQuery() in Power BI
Current Behavior
Value.NativeQuery() supports parameter placeholders during Power Query preview evaluation, but parameter bindings are not preserved during DirectQuery runtime execution after Close & Apply.
This causes runtime SQL execution failures such as:
Must declare the scalar variable @Param -- for MS SQL Server database
OR
ORA-01008: not all variables bound -- for Oracle database
when the DirectQuery engine reconstructs SQL without rebinding parameters.
Why Existing Alternatives Are Insufficient
1. String Concatenation
Unsafe for text parameters.
Example:
Value.NativeQuery(
Source,
"SELECT * FROM Table WHERE Name = '" & Param & "'"
)
Problems:
- SQL injection exposure
- manual escaping complexity
- loss of type-safe parameterization
- inconsistent query plans
2. Stored Procedures
Not viable in many enterprise/vendor-managed environments:
- read-only access
- no schema modification permissions
- SaaS/vendor-controlled databases
3. Query Folding
Folding applies transformations after source query generation in many cases.
This does not support scenarios where parameters must:
- alter joins
- constrain CTEs
- influence optimizer behavior
- reduce scanned partitions
- control source-side execution logic
Suggested Feature
Add official runtime parameter binding support for Value.NativeQuery() in DirectQuery mode.
Value.NativeQuery(
Source,
"
SELECT *
FROM Sales
WHERE SaleDate >= @StartDate
AND SaleDate < @EndDate
",
[
StartDate = StartDateParam,
EndDate = EndDateParam
]
)
with guaranteed preservation of:
- parameter metadata
- parameter values
- parameter types
- prepared statement semantics
through the full DirectQuery execution pipeline.
Additional Enhancement Ideas
Microsoft could strengthen the proposal further with optional features like:
A. Typed Parameter Contracts
[
StartDate = type date,
CustomerId = Int64.Type
]
to ensure providers bind correctly.
B. Safe Dynamic Lists
Support:
WHERE Region IN @RegionList
with structured array binding instead of string expansion.
Why This Matters
This capability would:
- improve security
- reduce SQL injection risk
- improve DirectQuery performance
- support enterprise governance
- enable vendor-managed read-only environments
- align Power BI with modern parameterized query behavior available in other BI/data platforms
Recent ideas
How to Back Up and Restore a Fabric Lakehouse for Debugging
Is there a way to clone a Lakehouse, including its data, in Microsoft Fabric? When we encounter a data issue in Production, our usual approach is to take a backup of the database, restore it to a se...gsrinivasan5 hours agoNew MemberNew39Views0likes1CommentTenant Administration for Fabric Cloud Connections - Enterprise Governance Gap
Microsoft Fabric currently provides robust security around cloud connections by treating them as user-owned securable resources. While this model works well for personal connections, it creates signi...hrenollet6 hours agoRegular VisitorNew77Views7likes1CommentEnable Ownership Change / Take‑Over for Mirrored Database Items in Fabric
Mirrored DBs do not support ownership transfer today. This becomes an issue when someone leaves the company. And the user tied to the ownership is beeing disabled. That means you need to recreate the...Sigurd8 hours agoNew MemberNew875Views25likes3CommentsOption to hide item counts in filter pane
Allow report authors to hide counts displayed next to filter values while preserving filtering functionality. Currently, Power BI displays record counts next to values in filter panes and certain s...saul_galdamez10 hours agoNew MemberNew22Views0likes0CommentsAllow Detect Data Changes for Historic Data Outside Incremental Window
In Power BI Incremental Refresh,Detect Data Changes only works inside the incremental refresh window. If historic data gets updated, Power BI cannot detect or refresh it unless I expand the increment...NAGAKEERTHI_Y14 hours agoNew MemberNew119Views1like1Comment