Forum Discussion

CTouu's avatar
CTouu
Frequent Visitor
3 years ago
Solved

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, 

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

9 Replies

  • 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.

  • CTouu's avatar
    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]) 

    • lbendlin's avatar
      lbendlin
      Super User
      I decide which of the parameter value to use in the query editor 

      How?

      • CTouu's avatar
        CTouu
        Frequent Visitor

        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.

  • CTouu's avatar
    CTouu
    Frequent Visitor

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