Forum Discussion
Native database queries are run multiple times when refreshing
I am using Native Database Queries as some of the logic needed to extract data is complex and there is already well tested SQL to get the right data.
However, what I am finding is that if I build a table of data (Table1) using a Native Query and then I create a second table from the first using:
let
Source = #"Table1", ...
then when I refresh the data from Power BI through the Gateway that the SQL under the Native Query is run multiple times (I know as it takes a while to run and I can see multiple jobs in the SQL Activity Monitor.
I had assumed that if you built one table from another that the first table would be built and then the other built from it - is there some way I can force this behaviour as having a long running SQL query running multiple times does not make sense?
6 Replies
- Phil_SeamarkMicrosoft Employee
How much transformation are you doing in the Query Editor?
If it's not too heavy and you really need to restrict how much you call your source, you can always duplicate your table in DAX
- andrewsimmansHelper I
Hi Phil
I need to join tables to form what is in essence a many to many between two tables. The logic is a bit complex to explain here but this is all about handling point in time reporting and thus being able to analyse information using historical dimension information for the date being reported, I then use DAX to filter out the relevant rows based on the date selected.
So I am really wanting to know if I can force the SQL to run just once on the query it is declared as the source for and not have it run again because I use that Power Query as a source for another Power Query.
Thanks
- AnonymousNot applicable
Hi andrewsimmans,
>>So I am really wanting to know if I can force the SQL to run just once on the query it is declared as the source for and not have it run again because I use that Power Query as a source for another Power Query.
You can create a duplicate query from original query and uncheck the "include the refresh" option of the duplicates query after the refresh.
Regards,
Xiaoxin Sheng