Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. 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.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
21 | |
21 | |
19 | |
13 | |
12 |
User | Count |
---|---|
41 | |
29 | |
23 | |
22 | |
22 |