Forum Discussion
Row over row logic
Whichever result is easiest to produce.
I could use any of these result columns:
| Doc | Line | Amount | Action# | Flag(start) | Flag(end) |
| 1 | 1 | 10 | 1 | X | |
| 1 | 2 | -10 | 1 | x | |
| 2 | 1 | -20 | 2 | x | |
| 2 | 2 | 20 | 2 | x | |
| 3 | 1 | 10 | 3 | x | |
| 3 | 2 | 10 | 3 | ||
| 3 | 3 | -20 | 3 | x | |
| 4 | 1 | 30 | 4 | x | |
| 4 | 2 | -30 | 4 | x | |
| 4 | 3 | 30 | 5 | x | |
| 4 | 4 | -40 | 5 | ||
| 4 | 5 | 10 | 5 | x |
Got it. I think this works, but I created this as a measure now instead of a calculated column like the previous approach. I set this up to represent your "Flag(end)." This could be easily modified for the other scenario if that's desired, though. Here's the new calc:
- Aron_Moore7 years agoSolution Specialist
Awesome!
I modified to a calculated column and switched to flagging the start.
Flag = IF(SUMX(FILTER(ALL(Table1),Table1[Index]< EARLIER(Table1[Index])),[Amount]) = 0,1)Thanks again! - Aron_Moore7 years agoSolution Specialist
Uh oh.
Added the column to the actual data, ~550k rows, and Power BI just spins "Working on it"....
Anyone have tips for optimization? Maybe replicate this logic with M? But how?
- Anonymous7 years agoNot applicable
Not sure what your data architecture/data structure looks like, but if I were you, I would try to put a calculation like this on the DB side. It's at the lowest grain of data and could just be incorporated into your driving table.