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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
RichardBroadley
Frequent Visitor

Can't change data source when using Value.NativeQuery

Apologies if this is already answered in another post elsewhere. I tried searching for a relevant post but my searches didn't turn up anything useful. But if it is answered elsewhere I'd appreciate if you could direct me to the post?

 

Anyhow, I'm trying to find out why, when using Value.NativeQuery the data source details (server and database) can't be changed outside of the Advanced Editor.

 

With a simple query using the Sql.Database with the Query option it is possible to change the data source details. For example, with this query:

RichardBroadley_0-1741596206089.png

It is possible to change the source details both using the Data Source Settings dialog in the Power BI Desktop app (the Change Source button is enabled) and also through API calls when the pbix is published to a workspace.

RichardBroadley_1-1741596325731.png

 

But when the query is changed to use Value.NativeQuery so that incremental refresh can be configured the data source settings can't be changed outside the Advanced Editor. Here is the changed query details:

RichardBroadley_2-1741596402846.png

 

But with this query the Change Source button on the Data Source Settings dialog is disabled:

RichardBroadley_3-1741596461581.png

 

And, more importantly, the API calls to change the data source details fail when the pbix is published to a workspace.  We are trying to deploy a data model / pbix for a number of clients. When the data model was small the refresh wasn't too resource intensive but the model has grown both in structure and in data as clients use it more and more so we need to move to incremental refresh as we're now hitting resource limits when the bigger clients refresh their data. The above example is using one query, but the data model we've developed is using multiple queries so it's not feasible to edit all the queries for all clients whenever we make a change, so we need a way of changing the data source programatically. 

 

Any help would be appreciated.

1 ACCEPTED SOLUTION
Deku
Super User
Super User

You don't need to use native query for incremental refresh. Query folding means powerquery steps can be folded into a query that is sent to the data sources. 

 

So you can just use Views that are centrally updated, and use powerquery for incremental refresh

 

Like this

 

let

  Source = Sql.Database("dwdev02","AdventureWorksDW2017"),

  Data = Source{[Schema="dbo",Item="FactInternetSales"]}[Data],

  #"Filtered Rows" = Table.SelectRows(Data, each [OrderDateKey] >= Int32.From(DateTime.ToText(RangeStart,[Format="yyyyMMdd"]))),

  #"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each [OrderDateKey] < Int32.From(DateTime.ToText(RangeEnd,[Format="yyyyMMdd"])))

in

  #"Filtered Rows1"


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

3 REPLIES 3
Deku
Super User
Super User

You don't need to use native query for incremental refresh. Query folding means powerquery steps can be folded into a query that is sent to the data sources. 

 

So you can just use Views that are centrally updated, and use powerquery for incremental refresh

 

Like this

 

let

  Source = Sql.Database("dwdev02","AdventureWorksDW2017"),

  Data = Source{[Schema="dbo",Item="FactInternetSales"]}[Data],

  #"Filtered Rows" = Table.SelectRows(Data, each [OrderDateKey] >= Int32.From(DateTime.ToText(RangeStart,[Format="yyyyMMdd"]))),

  #"Filtered Rows1" = Table.SelectRows(#"Filtered Rows", each [OrderDateKey] < Int32.From(DateTime.ToText(RangeEnd,[Format="yyyyMMdd"])))

in

  #"Filtered Rows1"


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Thank you, Deku, for that. I have re-jigged the queries and initial testing does seem to confirm that incremental refresh is working. However, what concerns me is that for every query done like this I'm getting a warning from Power BI saying that it's not recommended to use incremental refresh:

RichardBroadley_0-1741608073177.png

I went the Value.NativeQuery route initially because that removed the warnings.

If you look at the SQL server logs or use SQL profiler you can confirm if query folding is happening. You can look at the query and see whether the date filters for incremential refresh are included in the query for example


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.