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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
johnwood
New Member

Converting an Excel source to SQL

Hi all

Using Power BI Desktop, i have created a series of dashboards which at present are sourcing data from a set of excel files created from various data sources, mainly Dynamics CRM.  I now want to convert from excel sources to direct SQL queries, without having ro revisit all my hard work!  Is there an easy way of doing this?

Many thanks!

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

The easiest/safest way to do this is to probably create a new query to your SQL data source in Desktop and get it to a state such that all of the columns are the same names, etc. Basically so that you have two queries, your original to Excel and the new one to SQL that end up with exactly the same end table. Edit your 2nd query and go to View | Advanced Editor. Copy the "M" code. Edit your 1st query and go to View | Advanced Editor. Select all of your "M" code and replace it with the paste of your 2nd query.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Community Champion
Community Champion

The easiest/safest way to do this is to probably create a new query to your SQL data source in Desktop and get it to a state such that all of the columns are the same names, etc. Basically so that you have two queries, your original to Excel and the new one to SQL that end up with exactly the same end table. Edit your 2nd query and go to View | Advanced Editor. Copy the "M" code. Edit your 1st query and go to View | Advanced Editor. Select all of your "M" code and replace it with the paste of your 2nd query.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Many thanks!  As with manythings in life, it's obvious once you know how 🙂

@johnwood if i understood the question correctly you can also just goto File <- Import Excel workbook contents on Power BI Desktop. This will convert your Excel Files into PBI Files as described here

Business Intelligence Architect / Consultant

Hi PowerBIGuy

What I am doing is using excel extracts from our CRM system to generate data on which I am developing our BI reports.  In order to move the project into a production environment, I wanted to convert the source type to a direct SQL query, and the reply I got from SMOUPRE is exactly teh answer I was looking for!

Thanks!

John

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.