cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GeorgeK-VL Helper I
Helper I

Creating a template and managing a MySQL DB Name as a parameter

Hello everyone,

 

I want to create a power bi template that includes all the tables of a MySQL DB for one of my clients and save it as a template. All my clients have exactly the same tables and I collect the same exact data, but i have different DB names for each one of them.

 

What I need is when I open the template to give the DB name of the client I want to create a report for and update all the tables with the correct DB name. 

So far, I have to edit the schema of each table and change the DB name manually. If there is a way to automate that it will save lots of time.

Thank you in advance,


George

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator v-yuezhe-msft
Moderator

Re: Creating a template and managing a MySQL DB Name as a parameter

@GeorgeK-VL,

You can create a database name parameter in your PBIX file following the instructions in this blog, then add a new blank query and paste the code below to the Advanced Editor of the blank query.

1.PNG

let
    Source = MySQL.Database("Server", ""&dbname&"", [ReturnSingleDatabase=true]),
    TTable = Source{[Schema=""&dbname&"",Item="TableName"]}[Data]
in
    TTable


After that, create Power BI template following the guide in the blog below.

https://powerbi.microsoft.com/en-us/blog/deep-dive-into-query-parameters-and-power-bi-templates/

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
GeorgeK-VL Helper I
Helper I

Re: Creating a template and managing a MySQL DB Name as a parameter

I have found the solution. I will provide information shortly.

Moderator v-yuezhe-msft
Moderator

Re: Creating a template and managing a MySQL DB Name as a parameter

@GeorgeK-VL,

You can create a database name parameter in your PBIX file following the instructions in this blog, then add a new blank query and paste the code below to the Advanced Editor of the blank query.

1.PNG

let
    Source = MySQL.Database("Server", ""&dbname&"", [ReturnSingleDatabase=true]),
    TTable = Source{[Schema=""&dbname&"",Item="TableName"]}[Data]
in
    TTable


After that, create Power BI template following the guide in the blog below.

https://powerbi.microsoft.com/en-us/blog/deep-dive-into-query-parameters-and-power-bi-templates/

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors
Top Kudoed Authors