Forum Discussion
point difference between individual points versus average trend line value
- 6 years ago
I was able to solve this by creating the following measures:
ChurnCalc average =AVERAGEX(ALLSELECTED('ChurnDigital'[WeekId]),CALCULATE([Churn]))Churn var to avg = ChurnDigital[Churn] - ChurnDigital[ChurnCalc average]
[Edited By Admin]
Hi there.
After having read all of this and seen the code...
Please reconsider!
Especially when I saw this:
StopCopiesTotal = CALCULATE(SUM(ChurnDigital[StopCopies]),DATESBETWEEN(ChurnDigital[WeekId],[MinDate],[DistinctMaxDate]))
DATESBETWEEN is a time-intel function and it works well and correctly ONLY when used on the date column of a real Date table. You are using it on a fact table and in addition on a field that almost certainly is not a date column but a mere integer.
Please have a good look at the definition of the function:
https://dax.guide/datesbetween/
Check the arguments of it in particular.
Best
D
- spena6 years agoFrequent Visitor
I am lost as to why you are so horrified. My calculations using this function are working perfectly fine. WeekId is a datetime datatype that I have brought in from SQL.
The reason this calculation works is because it is calculating a cume between a given set of dates based on whatever the starting WeekId is that I have set in my date slider. The sum will vary. My StopCopiesTotal numbers are there for you in the table I attached.
Your response was very rude and not helpful at all.
- Anonymous6 years agoNot applicable
[Edited by Admin]
I'm quite sure what you are doing is incorrect and potentially very dangerous.
No offense was meant. I was just trying to warn you against writing such things.
By the way, check to make sure you have proper Calendar dimension in your model and perform slicing directly on the fact table, it'll be hard for you to write correct formulas if you don't, especially when manipulation of time is involved.
Best
D