Forum Discussion
Anonymous
3 years agoNot applicable
How can I refactor my DAX cumulative code which is extremely slow
I have written this DAX code which calculates the cumulative total, however, it is extremely slow when I drill down from monthYear to a daily granularity.
partnerSignUpsCumulative =
VAR MaxDate = MAX ( Leads[createddate] )
RETURN
CALCULATE (
[partnersSigned],
FILTER ( ALLSELECTED (Leads),
Leads[createddate] <= MaxDate
)
Is there a way to refactor this code to make it perform faster?
2 Replies
- jdbuchanan71
Super User
Anonymous
The first item that jumps out at me is, you don't want to FILTER over a whole table. Does this help the speed?
partnerSignUpsCumulative = VAR MaxDate = MAX ( Leads[createddate] ) RETURN CALCULATE ( [partnersSigned], FILTER ( ALLSELECTED (Leads[createddate]), Leads[createddate] <= MaxDate ) - AnonymousNot applicable
Doing that makes it not a cumulative total anymore, it stops accumulating over each day rather it just shows the total for each specific day rather than carrying it over