Forum Discussion
Is nested sumx the right approach
- Anonymous2 years ago
Hi debenaire ,
Nesting SUMX functions can indeed lead to performance issues because it requires iterating over rows multiple times, which can be resource-intensive.
Instead of nesting SUMX functions, consider restructuring your calculations to minimize the number of row context iterations. You can do this by trying to move calculations outside of the SUMX function if possible.
So I think you can change the DAX code like this:
VAR ActualDataCheck = SUMX( Points, IF( ISBLANK([Actual Unit, Cost and Carbon]), BLANK(), [Actual Unit, Cost and Carbon] ) ) VAR Result = IF( ISBLANK(ActualDataCheck), CALCULATE( MAX(Target[Daily Target]), FILTER( Target, Target[TargetType] = 0 ) ), ActualDataCheck ) RETURN SUMX( Calendar_, Result )Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi debenaire ,
Nesting SUMX functions can indeed lead to performance issues because it requires iterating over rows multiple times, which can be resource-intensive.
Instead of nesting SUMX functions, consider restructuring your calculations to minimize the number of row context iterations. You can do this by trying to move calculations outside of the SUMX function if possible.
So I think you can change the DAX code like this:
VAR ActualDataCheck =
SUMX(
Points,
IF(
ISBLANK([Actual Unit, Cost and Carbon]),
BLANK(),
[Actual Unit, Cost and Carbon]
)
)
VAR Result =
IF(
ISBLANK(ActualDataCheck),
CALCULATE(
MAX(Target[Daily Target]),
FILTER(
Target,
Target[TargetType] = 0
)
),
ActualDataCheck
)
RETURN
SUMX(
Calendar_,
Result
)
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks so much!