Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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 | employe | points | output |
| 200 | A | 100 | -10 |
| 200 | B | 150 | 10 |
| 200 | C | 130 | 50 |
| 190 | A | 110 | |
| 190 | B | 140 | 40 |
| 190 | C | 80 | 30 |
| 180 | C | 50 | |
| 180 | B | 100 |
My function returns different values than the output from the table as if it was looking for the maximum value from all rows.
Solved! Go to Solution.
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
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
How large is the dataset?
Here are the articles to resolve the memory issues.
How to Fix Memory Allocation Error in Power BI Desktop - Monocroft
Proud to be a Super User! | |
It is not large, as it has about 100,000 records
Would need more information to understand the root cause. Are you getting the error after creating a calculated column? and make sure the dataset is sorted as well
Proud to be a Super User! | |
I solved this problem and as you can see in the picture sometimes it counts right and sometimes wrong. What could this be due to?
Hi,
Create a new column to calculate the difference in points between the current row and the previous row for the same employee:
Proud to be a Super User! | |
Thanks for your answer 🙂 It should work but yet a message about insufficient memory appears.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 4 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 25 | |
| 17 | |
| 9 | |
| 8 | |
| 7 |