Forum Discussion
Optimize DAX
- 4 years ago
A quick win would be to use variables to store the results of calculations which are currently being done multiple times. e.g.
CALCULATE ( SUM ( Worksheet[LE Volume] ), ALLSELECTED ( Worksheet ), VALUES ( Worksheet[Month] ), VALUES ( Worksheet[Category] ) )is done multiple times and must be calculated every time. Store the result in a variable so you only have to do the calculation once.
- 4 years ago
Hi mlozano
1. Must the measure be that long?
2. Have you removed all duplication from it?
3. Instead of IF's, have you tried to use SWITCHes?
4. Have you tried to optimize each small piece of the measure so that it's fast when applicable?
5. The problem is that if you have many variables calculated outside of IF/SWITCH, then DAX very often, or even 95%+ of the time, will try to calculate EVERYTHING regardless of whether a variable will or will not be needed for the final calculation. Therefore it's so important to place the calculation of variables in the correct places, that is under IF/SWITCH.
Hi mlozano
1. Must the measure be that long?
2. Have you removed all duplication from it?
3. Instead of IF's, have you tried to use SWITCHes?
4. Have you tried to optimize each small piece of the measure so that it's fast when applicable?
5. The problem is that if you have many variables calculated outside of IF/SWITCH, then DAX very often, or even 95%+ of the time, will try to calculate EVERYTHING regardless of whether a variable will or will not be needed for the final calculation. Therefore it's so important to place the calculation of variables in the correct places, that is under IF/SWITCH.