Forum Discussion
Refresh failed because this semantic model requires a gateway. How to avoid without gateway?
- 1 year ago
Hi jaryszek ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If the responses has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank you!!
So all this code from Microsoft :
let
Environment = Parameter_Environment,
Source = if Environment = "Team" then
Csv.Document(File.Contents("ExcelPath"))
else if Environment = "Customer" then
Sql.Database("CustomerDBServer", "CustomerDB")
else
error "Unsupported environment"
in
Sourcewill not work anyway without gateway?
I heard also:
If you want to keep your approach, you have to disable the dev queries right before you publish the model to the web service.it will not work if i have used If statement refering to any even disabled query because it will require to have gateway still... even on Customer Environment.
You can handle this scenario best by using a parameter in Power Query that controls which data source to use. Define a parameter like SourceMode with values such as "Dev" and "Customer". In your Power Query logic, use an if-statement that switches data sources based on the parameter's value. For example, if the parameter is set to "Dev", pull from your CSV or GitHub. If it's set to "Customer", connect to the customer’s SQL database.
Before publishing the report to the customer's tenant, switch the parameter to "Customer" and make sure the queries using dev sources are either removed or disabled to prevent errors. Then publish with only the customer database source active. This way, the dataset remains refreshable on the customer side, assuming the CustomerDatabase is accessible through either a gateway or a direct connection.
This approach avoids the complexity of managing two separate datasets and keeps everything in a single PBIX file with conditional logic handling the data source.this is another solution from another power bi developer.
It seems that everybody advise to have swither and disabled queries but it seems to not be woring if even one query depends on this disabled one....
Best,
Jacek
You are "fighting the API". You are trying to do something that the Formula Firewall is actively trying to prevent.
https://learn.microsoft.com/en-us/power-query/data-privacy-firewall