Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
ms527
Regular Visitor

Cannot change Datasource when using Native Query to call Stored procedure

I have data source that I'm Calling a Stored Procedure to use Incremental Refresh in Power BI. Now I cannot change datasource as it is greyed out on account of using Native Query. i.e.

 

let
Source = Sql.Database("SERVERNAME", "DatabaseName"),
NativeQuery = Value.NativeQuery( Source, "EXEC sp_PBI_load_sales @StartDate, @EndDate", [StartDate = RangeStart, EndDate = RangeEnd], [EnableFolding=true] )
in
NativeQuery

 

This also breaks changing or creating datasource rule in the deployment pipeline.

1 REPLY 1
v-nuoc-msft
Community Support
Community Support

Hi @ms527 

 

Based on the details you provided, it appears that you are encountering limitations related to using native queries and stored procedures with Power BI's incremental refresh and data source management features.

 

Power BI's incremental refresh feature does not support using stored procedures directly, as described in the following link.

 

Query folding guidance in Power BI Desktop - Power BI | Microsoft Learn

 

Incremental refresh requires the ability to apply filters directly on the query to determine what data has changed, which is not possible with stored procedures because they encapsulate SQL queries.

 

Regarding the issue of the datasource option being greyed out, this is likely due to the use of a native query.

 

When you use a native query (), Power BI treats this as a custom SQL statement and limits certain functionalities, including changing the datasource through the UI, as it cannot guarantee that the new datasource will support the custom SQL without errors.

 

You can try the following to resolve the issue:

 

Modify the Approach for Incremental Refresh: Instead of using a stored procedure, consider implementing the logic directly in Power Query M language or using a view in your database that can be parameterized within Power BI.

 

This allows Power BI to manage the query folding and apply the necessary filters for incremental refresh.

 

Changing the Datasource: To change the datasource, you might need to manually edit the Power Query M code to replace the server and database names.

 

Regards,

Nono Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.