Forum Discussion
DAX Polynomial Regression Calculation Issue
- 5 years ago
I think the main problem here is this: COUNTX(VALUES(Table1[date]),Table1[date])
This is evaluated within the local filter context and returns 1 for each row corresponding to a single date.
Try this instead: COUNTROWS ( ALLSELECTED ( Table1[date] ) )
This is what I get when I make that change:
Good match except for x = 1.
Note that you need to make the same change for each of [a], [b], [c] or else change your final line of [values (poly fit)] to a*[zSequence1ToN]^2+b*[zSequence1ToN]+c (use the variables you've already computed instead of referencing other measures).
That's a facepalm moment. I was indeed using the measures instead of the variables. Thanks!
So the moral of the story is that local filter context is passed down through dependent variables too. That is something I would not have considered.
- AlexisOlson5 years agoSuper User
Yes. Each VAR is calculated within the local filter context.