Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I have been trying to learn more about Optimising Dax using a data sample from sqlbi (DAX Optimizations Examples with Alberto Ferrari) Orders Table has 1.6 million rows of data. I have two identical measures except one does not use variables. The measure with variables takes 14 seconds to execute and the other 0.5 seconds. I am unsure why variables are having an impact on performance.
Measure 1
To be able to answer the question one has to see the execution plans for both queries. There is no other way.
However, some things to observe:
1. The two measures (they are not queries!) are not logically equivalent.
2. The second one removes all filters from 'Date' BEFORE calculating the number of rows, so the logical expressions in filter can be totally ignored (in the presence of the assumed relationship). This is not the case in the first query when you first calculate the bounds and then use the bounds in the expression. These bounds stay put despite the ALL directive.
did really these querys return the same result?
Yes identical results just different execution times
User | Count |
---|---|
60 | |
22 | |
18 | |
18 | |
16 |
User | Count |
---|---|
86 | |
54 | |
54 | |
38 | |
21 |