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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
arkiboys2
Contributor

dataflow complex rule

in the dataflow gen2, I am adding a custom column with a very complex business rule.

for example:

if column2 = "xyz" and column3 != '765'

...

then custom_column = 'system1'

else if column2 = ...

...

for a complex rule is it ok the formula is very complex and probably around 50 + lines?

is it better to do this logic into a stored proc and update the table after the ingestion in dataflow?

thank you

1 ACCEPTED SOLUTION
liuqi_pbi
New Contributor III

Can you share the current IF statement? Or share some sample data and expected outcome? Maybe we can optimize it to reduce the complexity or reduce the lines.

 

If it's just a conditional judgment on the same row of data, there usually won't be a significant performance issue. And complexity isn't entirely determined by the number of lines.

 

When further optimization is not possible, it may be better to use stored procedures to implement the same logic on the data source side than to use Dataflow. For some simple logical operations, the M language used in the dataflow itself will be converted into SQL statements supported by the corresponding data source and executed by the data source.

View solution in original post

2 REPLIES 2
liuqi_pbi
New Contributor III

Can you share the current IF statement? Or share some sample data and expected outcome? Maybe we can optimize it to reduce the complexity or reduce the lines.

 

If it's just a conditional judgment on the same row of data, there usually won't be a significant performance issue. And complexity isn't entirely determined by the number of lines.

 

When further optimization is not possible, it may be better to use stored procedures to implement the same logic on the data source side than to use Dataflow. For some simple logical operations, the M language used in the dataflow itself will be converted into SQL statements supported by the corresponding data source and executed by the data source.

frithjof_v
Honored Contributor

In addition to what @liuqi_pbi mentioned here: "For some simple logical operations, the M language used in the dataflow itself will be converted into SQL statements supported by the corresponding data source and executed by the data source."

 

This is the automatic Query Folding mechanism in Power Query M.

 

In addition, if your source is SQL based and you wish to push complex transformations back to the source, you can write your own SQL query in the dataflow connection, in order to make the source SQL server do the processing job.

 

Also, just copying the raw data into a staging table in Fabric by using data pipeline copy or Dataflow Gen2 fast copy, and then run transformations on the staged data (e.g. stored procedure or notebook) before loading it into prod table, makes great sense.

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Free Fabric Certifications

Free Fabric Certifications

Get Fabric certified for free! Don't miss your chance.

January Fabric Update Carousel

Fabric Monthly Update - January 2026

Check out the January 2026 Fabric 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.

Users online (10,772)