Forum Discussion
DAX to M Code
HI itsmeanuj,
In fact, the M query is good at the shape and transform table structure and they are not suitable to handle calculations that loop through the whole table. They will spend more resources and may cause a 'memory leak' due to the looping calculations.
For your scenario, they should be related to your DAX formula which nested multiple batch variable loop through tables and spends multiple resource usage due to the looping. Also, the heavy data amount obviously increases the workload of the calculations.
For your calculated column expression, it includes:
four variables need to calculate through the whole table, two calculates on the table within the if statement, nest if statement with calculation result as condition, and redirects a calculation on table records;
The total calculation amount should be (4+2) * 'table rows' + 'table rows' * 'table row' = 6 * 150k +150K * 150k = 22.5b( 22,500,900,000)
Notice:
The nested looping will obviously multip the calculated amount.
The real calculated amount may not be similar to the supposed, they can be reduced by filters and resource reuse.
Perhaps you can take a look at the following blog to know how to optimize the nested iterators if help:
Optimizing nested iterators in DAX - SQLBI
Regards,
Xiaoxin Sheng