Forum Discussion
Schedule refresh stopped working.
- 8 years ago
Apparently Microsoft have made some changed to the service - atleast I am now able to schedule refresh on republished data models.
Hi sdjensen
Could you possibly check what the data sources are in the PBIX file?
I am hopeful that this might be a change between the the PBIX and what is on the Power BI Service Gateway
Also if you can confirm that there were not changes to the Gateway Data Sources in the Service?
I have now investigated this issue some more and had a 2 hour support call with Microsoft yesterday and I am now very sure that this is because that Microsoft has made some changes in the service and I have recreated the issues on our development environment. The issues only happen if we republish the model, if the model is already in the service we can schedule updates.
I work as a BI consultant and we have created several models (Sales, Finance, Stock etc) for Microsoft Dynamics NAV. When we developed the model, we wanted a model that we could install at our customers as easy as possible, hence we use parameters for server and database (to the SQL database) and also a parameter to loop over several tables in the source and merge these into one table.
To explain the issue you first have to understand the way Microsoft Dynamics NAV is structured. Each company using NAV can have multiple legal entities in the same database and in the database a set of tables is then created for each entity, using the entity name as part of the same name, so if a company have 2 entities called entity1 and entity2 – 2 sets of table is created for storing data. E.g. the table for storing customer metadata is called Customer, but in the database there is 2 table one called entity1$Customer and one called entity2$Customer.
Because of the way Microsoft Dynamics NAV structures it’s database and because we wanted a model where we had to change as little as possible to install it at our customers, every table we load is created with a function that can loop over multiple entities (called companies in our model) – this approach has worked for us since we started looking at this in the summer of 2016 and we have many customers using this model.
I will give you an example of our m-code that we use to load the data from Microsoft Dynamics NAV:
So we have a table called “CompaniesToLoad” – this is a manual table and it could look something like this
Then for each table we need to load into the model we first lookup the companies (entities) from the table above that we want to be included in the model (LoadCompany = 1), for each company we then run our SQL query and then merge the result of each query into one table – the example below is from the customer table:
let
//Get table containing each company from static table CompaniesToLoad where LoadCompany = 1
CompaniesToLoad = Table.SelectRows(CompaniesToLoad, each ([LoadCompany] = 1)),
//Get a list containing each value in CompanyTablePrefix
Company = Table.Column(CompaniesToLoad,"CompanyTablePrefix"),
//Define a function to get data from specified companies
Companies = (Company as text) =>
let
Source = Sql.Database(Server, Database, [Query="
--SQL Query Start
SELECT
'" & Company & "' + '-' + a.No_ AS 'KundeKey'
, a.No_ AS 'Kundenr.'
, a.Name AS 'Kunde Navn'
, COALESCE(a.Name,'Ukendt') + ' - ' + a.No_ AS 'Kunde'
, a.[Customer Posting Group] AS 'Debitor Bogf. grp.'
, COALESCE(c.[Name],'Ukendt') AS 'Kunde Land'
, a.City + ', ' + COALESCE(c.[Name],'Ukendt') AS 'Kunde By'
, COALESCE(a.[Salesperson Code],'N/A') AS 'Sælger Kode'
, COALESCE (b.Name, 'Ukendt') AS 'Sælger Navn'
, COALESCE (b.Name, 'Ukendt') + ' - ' + COALESCE(a.[Salesperson Code],'N/A') AS 'Sælger'
FROM [dbo].[" & Company & "$Customer] a
LEFT JOIN [" & Company & "$Salesperson_Purchaser] b
ON a.[Salesperson Code] = b.Code
LEFT JOIN [" & Company & "$Country_Region] c
ON a.[Country_Region Code] = c.Code
--SQL Query End
"])
in
Source,
//Call above select for each company
LoadCompanies = List.Transform(Company, each Companies(_)),
CombineData = Table.Combine(LoadCompanies),
EnglishTranslation = Table.RenameColumns(CombineData,{{"Kundenr.", "Customer No."}, {"Kunde Navn", "Customer Name"}, {"Kunde", "Customer"}, {"Debitor Bogf. grp.", "Customer Posting Grp."}, {"Kunde Land", "Country"}, {"Kunde By", "City"}, {"Sælger Kode", "Salesperson Code"}, {"Sælger Navn", "Salesperson Name"}, {"Sælger", "Salesperson"}})
in
EnglishTranslation
I tried creating a model where I have removed the loop from all our tables and published this to my workspace and if I do this I am able to schedule the refresh – the above code then looks like this:
let
Source = Sql.Database(Server, Database, [Query="
--SQL Query Start
SELECT
'CRONUS EXT International Ltd_' + '-' + a.No_ AS 'KundeKey'
, a.No_ AS 'Kundenr.'
, a.Name AS 'Kunde Navn'
, COALESCE(a.Name,'Ukendt') + ' - ' + a.No_ AS 'Kunde'
, a.[Customer Posting Group] AS 'Debitor Bogf. grp.'
, COALESCE(c.[Name],'Ukendt') AS 'Kunde Land'
, a.City + ', ' + COALESCE(c.[Name],'Ukendt') AS 'Kunde By'
, COALESCE(a.[Salesperson Code],'N/A') AS 'Sælger Kode'
, COALESCE (b.Name, 'Ukendt') AS 'Sælger Navn'
, COALESCE (b.Name, 'Ukendt') + ' - ' + COALESCE(a.[Salesperson Code],'N/A') AS 'Sælger'
FROM [dbo].[CRONUS EXT International Ltd_$Customer] a
LEFT JOIN [CRONUS EXT International Ltd_$Salesperson_Purchaser] b
ON a.[Salesperson Code] = b.Code
LEFT JOIN [CRONUS EXT International Ltd_$Country_Region] c
ON a.[Country_Region Code] = c.Code
--SQL Query End
"]),
EnglishTranslation = Table.RenameColumns(Source,{{"Kundenr.", "Customer No."}, {"Kunde Navn", "Customer Name"}, {"Kunde", "Customer"}, {"Debitor Bogf. grp.", "Customer Posting Grp."}, {"Kunde Land", "Country"}, {"Kunde By", "City"}, {"Sælger Kode", "Salesperson Code"}, {"Sælger Navn", "Salesperson Name"}, {"Sælger", "Salesperson"}})
in
EnglishTranslation- sdjensen8 years agoSolution Sage
By further investigating I have narrows my issues down to the following to lines of code where I loop over the different companies and then merge the result into one table...
LoadCompanies = List.Transform(Company, each Companies(_)), CombineData = Table.Combine(LoadCompanies),The parameters (" & Company & ") in the code is not the issues - if I create a static parameter for company (like my server and database parameters) and publish this model to the service I am able to schedule the refresh.
I suspect that MS in the lastest change to the service have made some kind validation against the SQL source, but my company parameter is a list of values and not just one value, hence validation is not posible, because the company parameter is unknown until the list is populated with values and used in the function. It's really anoying - we have been using this technique since the summer of 2016 and have sevaral customers that is using our models, and right now we can't make changes to any of these or install the models at new customers.
- Framet8 years agoResolver II
I ended up removing all parameters from my queries and functions in an attempt to get this to load reliably but previosuly this hadn't helped. I also had a recursive query across workbook tabs of an excel file which I had to replace with an equivilent SSIS package and point Power BI at a SQL table even though this worked without issue for many weeks.
On my issue, I have recently heard back from Microsoft support who indicate something has been "fixed" with the cluster and my reports indeed refresh again so perhaps we have different issues with the same error message?
- Anonymous8 years agoNot applicable
Hi Framet, instead of creating a full SSIS package to create a table you can always create a view to pull the data into your model. Since you are refreshing on a schedule pulling from a view should not be determinal.
- sdjensen8 years agoSolution Sage
Apparently Microsoft have made some changed to the service - atleast I am now able to schedule refresh on republished data models.