Forum Discussion
PrevRow + index problem
- 5 years ago
Hello @Vieiraguilherme ,
You can create this computed column instead of the index column:
Sort = VAR _rank = RANKX ( FILTER ( ALL ( 'Table' ), 'Table'[ID Number] = EARLIER ( 'Table'[ID Number] ) ), 'Table'[Changed On Timestamp], , ASC, DENSE ) VAR _sort = IF ( [ID Number] = MIN ( 'Table'[ID Number] ), _rank, _rank + CALCULATE ( COUNTROWS ( FILTER ( ALL ( 'Table' ), 'Table'[ID Number] < MAX ( 'Table'[ID Number] ) ) ) ) ) RETURN _sortNext, create a measure to get the previous row:
_prerow = CALCULATE ( MAX ( 'Table'[Changed On Timestamp] ), FILTER ( ALL ( 'Table' ), 'Table'[Sort] = CALCULATE ( MAX ( 'Table'[Sort] ), FILTER ( ALL ( 'Table' ), 'Table'[Sort] < MAX ( 'Table'[Sort] ) ) ) ) )Current Result:
When you add a new row to the table, the value of the previous row is still received successfully:
Attached a sample file in the next one, hopes to help you.
Best Looks,
Yingjie LiIf this post helps, please consider Accepting it as the solution to help the other members find it more quickly.
Hello @Vieiraguilherme ,
You can create this computed column instead of the index column:
Sort =
VAR _rank =
RANKX (
FILTER ( ALL ( 'Table' ), 'Table'[ID Number] = EARLIER ( 'Table'[ID Number] ) ),
'Table'[Changed On Timestamp],
,
ASC,
DENSE
)
VAR _sort =
IF (
[ID Number] = MIN ( 'Table'[ID Number] ),
_rank,
_rank
+ CALCULATE (
COUNTROWS (
FILTER ( ALL ( 'Table' ), 'Table'[ID Number] < MAX ( 'Table'[ID Number] ) )
)
)
)
RETURN
_sort
Next, create a measure to get the previous row:
_prerow =
CALCULATE (
MAX ( 'Table'[Changed On Timestamp] ),
FILTER (
ALL ( 'Table' ),
'Table'[Sort]
= CALCULATE (
MAX ( 'Table'[Sort] ),
FILTER ( ALL ( 'Table' ), 'Table'[Sort] < MAX ( 'Table'[Sort] ) )
)
)
)
Current Result:
When you add a new row to the table, the value of the previous row is still received successfully:
Attached a sample file in the next one, hopes to help you.
Best Looks,
Yingjie Li
If this post helps, please consider Accepting it as the solution to help the other members find it more quickly.
Hi, do you thing this collumn/measure will work with a BI that have 250.000 rows?
- v-yingjl5 years agoCommunity Support
Hi Anonymous ,
The calculated column and measure both should work.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.