I’ve been working my way through the DAX optimization courses and trying to better understand how to optimize my DAX code.
I have a sample file attached and wanted to know what is the best way to write a calculation measure with a filter condition and place that measure into a matrix.
As a general rule to thumb, do not use filter function when all you do is apply some filter to a column. Filter function is an iterator that usually materialize the table and force formula engine to scan it line by line and that is expensive.
In your example, you told DAX to materialize entire Transport Mode table, iterate through it line by line, and check if related Forms[Status] ) = “Granted”.
Thank you both for the suggestions. I can confirm that after implementing this into my main model it has significantly reduced the load times and both versions of the measure works.
Some observations:
When using the distinctcount DAX function, I still found the load time of the visual slow.
Having the measure written this way increased it significantly:
Hi @adsa,
In the example that you have shared, I have tried this measure in 3 different ways and the one that is currently in it seems to be the one that takes the least time.