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

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

Reply
gramespa
Frequent Visitor

Add SQL statements in advanced window or rebuild in M

Hi all,

I am connecting Power BI to a SQL Database and need some sql statements to create a new table based on joining several other tables with similar keys. Some have relations some dont. 

 

I have no trouble building what i need in SQL but i am not so sure about doing it in M.

Is it "best practice" to add SQL statements directly as advanced option or connect to Database and rebuild what i need in M? And if so is there any guidance how to transfer common statements like Select, cast, join, where etc?

 

Thank you all1

2 REPLIES 2
VasTg
Memorable Member
Memorable Member

@gramespa 

 

If you are using advanced window to run the SQL, some of the features like query folding can't be achieved.

 

But I always go with it because I know my SQL is right, tune it, bring in only the necessary columns and rows etc.

 

All I do in M query is to select the datatype and/or add custom/conditional columns for sorting,grouping etc..

 

On the flip side, If yo do it with M query, it has to read all the rows and transform the data in the way you need in Power BI.

 

But is it a "Best practise", I don't know. Test both the approaches and see which one loads faster.

 

If this helps, mark it as a solution

Kudos are nice too.

Connect on LinkedIn

Thank you for sharing you opinion in this! Since data size is not an issue in this case i might go for the advanced window and be sure what i am doing is correct.

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Kudoed Authors