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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
CTouu
Frequent Visitor

ODBC Url connection How to put a parameter

Hi ! 

 

I've got a simple (I think) issue. 
I have a simple connection to a Postgre DB Connection by ODBC (i don't use the postgre connector, don't need to propose). 

I have several DBs and I want to switch between them. 

 

In the source of each query I've got this : 

= Odbc.DataSource("Driver={PostgreSQL Unicode(x64)};Server=localhost;Port=5432;Database=databasename;", [HierarchicalNavigation=true]) 

 

I created a parameter with a list of several values : 

1database1
2database2
3

database3

 

But I can't manage to add this parameter instead of my "databasename" which is harcoded. 


Thank you by advance for your help, 

1 ACCEPTED SOLUTION

= Odbc.DataSource("Driver={PostgreSQL Unicode(x64)};Server=localhost;Port=5432;Database=" & databasename & ";", [HierarchicalNavigation=true]) 

View solution in original post

9 REPLIES 9
CTouu
Frequent Visitor

I put it in the query editor instead of "databasename" I want to add a parameter but it doesn't work

CTouu
Frequent Visitor

I'm in Power Query in the Desktop. 

I decide which of the parameter value to use in the query editor 

I want to add the parameter name after "database"

= Odbc.DataSource("Driver={PostgreSQL Unicode(x64)};Server=localhost;Port=5432;Database=databasename;", [HierarchicalNavigation=true]) 

I decide which of the parameter value to use in the query editor 

How?

In the Source Query : 

= Odbc.DataSource("Driver={PostgreSQL Unicode(x64)};Server=localhost;Port=5432;Database=databasename;", [HierarchicalNavigation=true]) 

 

I want to add a parameter name instead of "databasename" because for now it's hardcoded and I want the database name to be dynamic.

Why does it have to be a multi choice parameter? Could it be a scalar parameter instead?

 

Are you trying to implement your own version of deployment pipelines?

I think you didn't understood my issue. 

I just want to know how to variabilize an ODBC Source in the Query Editor 

For example : 

I need to import 23 tables

if I have a DEVELOPMENT database with a dbname A

and a PROD database with a dbname B

I want to know how to switch the dbname without having to change the dbname manually in each of the 23 tables 

= Odbc.DataSource("Driver={PostgreSQL Unicode(x64)};Server=localhost;Port=5432;Database=" & databasename & ";", [HierarchicalNavigation=true]) 

yes it works !! Thank you very much for your help ! I missed the & & characters !

lbendlin
Super User
Super User

how do you decide which of the parameter values to use?

 

Note that whatever you try to do here it will not work in the Power BI service.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.