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.
Hi,
I was wondering whether it's possible to reuse power query M code in multiple databases if they have the same or similar data structure?
Currently I have a Power BI project which contains a dataset generated from a SQL server database. I used power query editor to construct the data model and it seems to work fine. the various visualizations work fine. I have to create another Power BI project which queries a different SQL server database, but they have the same tables and structure as the original. I want to check whether there's an easy way to reuse the logic in the first project and apply it to the second, rather than copying and pasting the code.
Jason
Solved! Go to Solution.
Hi @Anonymous ,
We can user parameter to work on it. Please refer to the case as below.
https://community.powerbi.com/t5/Desktop/Changing-Data-Source/td-p/497753
Hello @Anonymous
you can create a function out of your query, and using parameters with the database as input... something like that:
(yourdatabase) =>
let
Source = Sql.Database(yourdatabase........
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hi all,
thanks for your help. Adding the parameters appear to do the trick.
Sincerely,
Jason
Hello @Anonymous
you can create a function out of your query, and using parameters with the database as input... something like that:
(yourdatabase) =>
let
Source = Sql.Database(yourdatabase........
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hi @Anonymous ,
We can user parameter to work on it. Please refer to the case as below.
https://community.powerbi.com/t5/Desktop/Changing-Data-Source/td-p/497753
Dataflows
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.