Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
9 | |
7 | |
7 | |
6 |
User | Count |
---|---|
21 | |
11 | |
10 | |
9 | |
8 |