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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ozanboy
Frequent Visitor

Parameter Function ODBC - Navigate between tables

Hi all,

In our SQL database every study create another table with different name(ID). With everynew table I have to follow same steps in query editor in order to shape them suitable for my graphs/charts etc. I want to create a parameter which can navigate between tables in our database and apply already created query steps automatically.

But I could not able to create a parameter/function which can navigate between tables.

Below is advanced query editor script. My study id is 20190409001 in this table. I want to create parameter for this id and change it any number I want. For example 20190409005.

Thanks in advance

 

let
Source = Odbc.DataSource("dsn=XX Database", [HierarchicalNavigation=true]),
Company_Database = Source{[Name="Company",Kind="Database"]}[Data],
#"20190409001_Table" = Company_Database{[Name="20190409001",Kind="Table"]}[Data]
in
#"20190409001_Table"

3 REPLIES 3
parry2k
Super User
Super User

@ozanboy you can achieve this by parameter, create new parameter in power query, let's say we call it TableName. 

 

now update your script as below.

 

let
Source = Odbc.DataSource("dsn=XX Database", [HierarchicalNavigation=true]),
Company_Database = Source{[Name="Company",Kind="Database"]}[Data],
#"20190409001_Table" = Company_Database{[Name=TableName,Kind="Table"]}[Data]
in
#"20190409001_Table"


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k 

I've created parameter named TableName and changed script as you said. but I got below error in query editor after apply changes.

CaptureParameter1.JPG

And when I click on edit settings it directs me to navigation window,

CaptureParameter2.JPG

Below all the tables in our database this image appears, it seems like it doesnot recognize TableName.

Then I also created function as TableName like below;

(TableName)=>
let
Source = Odbc.DataSource("dsn=XX Database", [HierarchicalNavigation=true]),
Company_Database = Source{[Name="Company",Kind="Database"]}[Data],
#"20190409001_Table" = Company_Database{[Name=TableName,Kind="Table"]}[Data]
in
#"20190409001_Table"

But got an again error message below and the advanced editor script of my error is like below.

CaptureParameter3.JPG

let
    Source = #"20190409001"(20190409003)
in
    Source

Second one is the table id I want to navigate, first one is the default table id.

Maybe somehow changing all the table ids in initial script with TableName?

Thanks

@ozanboy the change I proposed in the original query should work. Can you make sure name of the parameter you used in the query is exact match of parameter name, it is case sensitive.

 

Also make sure the value in parameter is not blank and you enter a valid table name. I don't expect you need to make much changes except change proposed in original reply.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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