Forum Discussion
Pan_Forex
Helper III
2 years agorow minus previous row
Hello, I am trying to count the difference in points between the latest ID and the previous one for each employee. I have a very simple bug somewhere and I can't find it... id emplo...
- 2 years ago
Total Points = SUM ( pan[points] )Output = VAR PreviousValue = CALCULATE ( [Total Points], OFFSET ( -1, ALL ( pan[employee], pan[id] ), ORDERBY ( pan[id], ASC ), PARTITIONBY ( pan[employee] ) ) ) VAR CurrentValue = [Total Points] VAR GroupingByID = ISINSCOPE ( pan[id] ) VAR Result = IF ( NOT ISBLANK ( PreviousValue ) && GroupingByID, CurrentValue - PreviousValue ) RETURN Result
Kaviraj11
Solution Sage
2 years agoHi,
Create a new column to calculate the difference in points between the current row and the previous row for the same employee:
Points Difference =
VAR CurrentPoints = [points]
VAR PreviousPoints =
CALCULATE (
MAX ( 'Table'[points] ),
FILTER (
ALL ( 'Table' ),
'Table'[id] < EARLIER ( 'Table'[id] )
&& 'Table'[employee] = EARLIER ( 'Table'[employee] )
)
)
RETURN
IF ( NOT ISBLANK ( PreviousPoints ), CurrentPoints - PreviousPoints )
- Pan_Forex2 years ago
Helper III
Thanks for your answer 🙂 It should work but yet a message about insufficient memory appears.