Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 20 | |
| 10 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 33 | |
| 31 | |
| 19 | |
| 12 | |
| 11 |