cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
AGo Member
Member

Parameter changing datasource type DB2->ODBC

Hi,

 

I have this M code and trying to return the TABLE1 table for conditionally 2 datasources (ODBC and DB2) which has the same structure.

I'm not good at M: I think that the third row generates  a parameter field, but I have yet created a parameter (called "parameter") as another datasource that I want to manage outside this code.

"parameter" is managed to have 2 pre-defined values selectable "ODBC" and "DB2".

For me, for a better understanding of the code structure, suppose that I also want to rename the field "LOREM" in "IPSUM".

 

 

let

#"Origine" = (para as text) =>
if para = "ODBC"
then

let
    Source = Odbc.DataSource("dsn=dsnname", [HierarchicalNavigation=true])
   in
    Source

else 

let
    Source = DB2.Database("servername", "test", [Implementation="IBM"])
in
Source in #"Origine"

 @v-yuezhe-msft

Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Parameter changing datasource type DB2->ODBC

Hi @AGo,

in M, every query step can be seen as a variable. So your requirement can be solved like this:

 

let
	Odbc = Odbc.DataSource("dsn=dsnname", [HierarchicalNavigation=true]),
	DB2 = DB2.Database("servername", "test", [Implementation="IBM"]),
	Origine = if para = "ODBC" then Odbc else DB2
in 
	Origine

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




3 REPLIES 3
Super User
Super User

Re: Parameter changing datasource type DB2->ODBC

Invoking @ImkeF


I have book! Learn Power BI from Packt


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Super User
Super User

Re: Parameter changing datasource type DB2->ODBC

Hi @AGo,

in M, every query step can be seen as a variable. So your requirement can be solved like this:

 

let
	Odbc = Odbc.DataSource("dsn=dsnname", [HierarchicalNavigation=true]),
	DB2 = DB2.Database("servername", "test", [Implementation="IBM"]),
	Origine = if para = "ODBC" then Odbc else DB2
in 
	Origine

Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Imke Feldmann

How to integrate M-code into your solution -- Check out more PBI- learning resources here -- Performance Tipps for M-queries




AGo Member
Member

Re: Parameter changing datasource type DB2->ODBC

Works like a charm! And thanks forthe functioning explaining.

Helpful resources

Announcements
Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Summit North America

Power Platform Summit North America

Register by September 5 to save $200

Virtual Launch Event

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 311 members 3,058 guests
Please welcome our newest community members: