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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
dragsdale
New Member

Which M functions support SQL code folding?

Does a resource exist listing which M fuctions can be code folded?  I am assuming it depends on the SQL engine, but it would be very helpful to know which M functions can be run on the database.

3 REPLIES 3
v-yingjl
Community Support
Community Support

Hi @dragsdale ,

Relational data source transformations that can be query folded are those that can be written as a single SELECT statement. A SELECT statement can be constructed with appropriate WHERE, GROUP BY, and JOIN clauses. It can also contain column expressions (calculations) that use common built-in functions supported by SQL databases.

Generally, the following list describes transformations that can be query folded.

  • Removing columns.

  • Renaming columns (SELECT column aliases).

  • Filtering rows, with static values or Power Query parameters (WHERE clause predicates).

  • Grouping and summarizing (GROUP BY clause).

  • Expanding record columns (source foreign key columns) to achieve a join of two source tables (JOIN clause).

  • Non-fuzzy merging of fold-able queries based on the same source (JOIN clause).

  • Appending fold-able queries based on the same source (UNION ALL operator).

  • Adding custom columns with simple logic (SELECT column expressions). Simple logic implies uncomplicated operations, possibly including the use of M functions that have equivalent functions in the SQL data source, like mathematic or text manipulation functions. For example, the following expressions returns the year component of the OrderDate column value (to return a numeric value).

  • Pivoting and unpivoting (PIVOT and UNPIVOT operators).

 

Please refer: Transformations that can achieve folding 

 

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

Thanks.

This is the same resource I looked at.  It sounds like no such rource exists to identify which M Fuctions (https://docs.microsoft.com/en-us/powerquery-m/power-query-m-function-reference) can become native. Overall I am very impressed with power bi's ability to convert to native sql. I will just keep checking.

Fowmy
Super User
Super User

@dragsdale 

Is your question on forcing query folding, the function is Value.NativeQuery() and EnableFolding=true

 

Refer to this article: 

https://blog.crossjoin.co.uk/2021/02/21/query-folding-on-sql-queries-in-power-query-using-value-nati...

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors