Forum Discussion
Get next 3 row values for current row
- 6 years ago
Hi Anonymous ,
If you want a measure in table visual, parry2k’s solution is proper and great.
But if you want actual column in table, We can create following calculate columns to meet your requirement.
Next 1 = var x = CALCULATE(MIN('Table'[Sequence]),FILTER('Table','Table'[Sequence]>EARLIER('Table'[Sequence]))) return CALCULATE(MAX('Table'[Value]),FILTER('Table','Table'[Sequence]=x))Next 2 = var x = CALCULATE(MIN('Table'[Sequence]),FILTER('Table','Table'[Sequence]>EARLIER('Table'[Sequence]))) return CALCULATE(MAX('Table'[Next 1]),FILTER('Table','Table'[Sequence]=x))Next 3 = var x = CALCULATE(MIN('Table'[Sequence]),FILTER('Table','Table'[Sequence]>EARLIER('Table'[Sequence]))) return CALCULATE(MAX('Table'[Next 2]),FILTER('Table','Table'[Sequence]=x))And the result like this,
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Greg,
That's right. Columns "Sequence" and "Value" are the source data, and results are what I need.
- Anonymous6 years agoNot applicable
Comment: The numbers in the "Sequence" column are illustrative, because they are the result of previous grouping commands. I use that column only to preserve date/time stamp, removed from this last table. I removed all unnecessary columns to avoid excessive processing time.
- parry2k6 years ago
Super User
Anonymous here you go, you can surely merge these measure to not create sequence measures
Next 1 Sequence = VAR __currentRow = SELECTEDVALUE ( Next[Sequence] ) RETURN CALCULATE ( MIN ( Next[Sequence] ), ALL ( Next) , Next[Sequence] > __currentRow ) Next 2 Sequence = VAR __currentRow = [Next 1 Sequence] RETURN CALCULATE ( MIN ( Next[Sequence] ), ALL ( Next) , Next[Sequence] > __currentRow ) Next 3 Sequence = VAR __currentRow = [Next 2 Sequence] RETURN CALCULATE ( MIN ( Next[Sequence] ), ALL ( Next ) , Next[Sequence] > __currentRow ) Next 1 = VAR __sequence = [Next 1 Sequence] RETURN CALCULATE ( SELECTEDVALUE ( Next[Value] ), ALL(), Next[Sequence] = __sequence ) Next 2 Sequence = VAR __currentRow = [Next 1 Sequence] RETURN CALCULATE ( MIN ( Next[Sequence] ), ALL ( Next) , Next[Sequence] > __currentRow ) * DIVIDE ( __currentRow, __currentRow ) Next 3 Sequence = VAR __currentRow = [Next 2 Sequence] RETURN CALCULATE ( MIN ( Next[Sequence] ), ALL ( Next ) , Next[Sequence] > __currentRow ) * DIVIDE ( __currentRow, __currentRow ) Value Max = SELECTEDVALUE( Next[Value] )and here is the output
- Anonymous6 years agoNot applicable
Hi parry2k !
I'm missing how did you calculate "Next 2" and "Next 3" measures, since you send "Next 2 Sequence" and "Next 3 Sequence" twice.