March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
25 | |
18 | |
15 | |
9 | |
8 |
User | Count |
---|---|
37 | |
32 | |
21 | |
16 | |
14 |