Showing results for 
Search instead for 
Did you mean: 
Aksel Frequent Visitor
Frequent Visitor

Use Power BI API to change connectionstring if in DirectQuery but Update parameters if not



Firstly, I'm not entirely sure if this is feasible, and since the process I'm referring to are actually set up and owned by a third party company a lot of this is guesswork..


We have a deployment process that a third party have developed for us that allows Dataset connection strings to be changed from our Dev environment to the Production evnironment, with requests from our organisation being automated via an email handler.


Since this process is updating the datasource for a dataset, it is restricted to Direct Query (no Mixed or Import storage reports will work), so we currently can't build any composite models which is in turn putting a lot of restrictions in movign forward with business requests.

My knowledge and experience using the API is admitedly limited, but I need to make recommendations back to the business about how we are using PBI and how we're going to manage scalability and perfromance in the future and the suggestion that we try using Aggregation tables in a composite model is currently a no-go due to hte Direct Query restriction outlined above.


The API method to automate changing from a Dev to a Prod environment is working (for DQ) and I have had some success previously using Parameters within a report to handle the Server and DB name, and then using the Update Parameters API as detailed here to automate promotion from Dev to Prod. However both of these approaches I have only used/seen in isolation..


Would it be theoretically possible to 'cascade' the two approaches so that at first contact it is assumed to be a DQ only report and therefore handled by the Update dataset connection string API method, but if that returns an error regarding the method not being available for Import (or in this case Mixed) models then try using the Update Parameters API method to complete the connection change ?


So a report would follow this logic:



        Update dataset connection string API method - would succeed for DQ only reports



                Update Parameters API method - would only be tried if report is not DQ only (or a genuine error occurs which would also error here and pass into the next catch)


                Return error messages

I should point out, that in both cases - Import or DQ - the server and db being changed to would be identical, just handled differently.


Thanks in advance!

Community Support Team
Community Support Team

Re: Use Power BI API to change connectionstring if in DirectQuery but Update parameters if not

Hi @Aksel ,


Based on my test, it is not possible to meet your requirement currently.You can come up a new idea about that and add your comments there to improve Power BI and make this feature coming sooner.





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

Helpful resources

Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Top Kudoed Authors
Users Online
Currently online: 400 members 3,438 guests
Please welcome our newest community members: