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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Creating a generic data source for a PQ query

Hi,

for a customer I need to manage the data loading from a SQL Server table in the dev environment and the data loading from the corresponding Oracle table in the prod environment. In other terms, I've two different data sources between two environments.

I thought to create an empty query having as a first row something like Source = Connection_string_param, where this parameters contains the database server, the database name, likely also the access credentials and perhaps a table name, e.g.:

- for the SQL Server source, Connection_string_param = Sql.Database("database_server", "database_name"),

- for the Oracle source, Connection_string_param = Oracle.Database("database_name").

Is it possible to create a such parametric query? Any helps to me, please? Is it possible switching somehow from a data source to the another one?

Many thanks

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Please see this article.  You should be able to adapt this approach.

Change the Source of Power BI Datasets Dynamically Using Power Query Parameters - RADACAD

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Microsoft Employee
Microsoft Employee

Please see this article.  You should be able to adapt this approach.

Change the Source of Power BI Datasets Dynamically Using Power Query Parameters - RADACAD

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


mahoneypat
Microsoft Employee
Microsoft Employee

There are several ways you could do this.  One simple one would be like this.  Just change the SourceToggle value away from 1 to change to prod.

 

let

SourceToggle = 1,

Source = if SourceToggle = 1 then Sql.Database(     ) else Oracle.Database(   ),

rest of query

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Hi,

I've SourceToggle as a PQ parameter, but after publishing the pbix on Power BI service I cannot edit this parameter.

How could I solve this issue? Thanks

Anonymous
Not applicable

Hi Pat,

thanks for your reply.

I've tried your suggest in pbi desktop and it functions rightly!

On power bi service after the publishing?

I'm interesting to know other ways to solve this issue. Is there any articles about this subject?

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.