Forum Discussion
sarvesh23p
3 years agoNew Member
Compare current record with previous record within same column on the basis date-time column
Hi All,
I have a table which have Date tiem columns and a data columns. Consider column name 'high'
I want to compare recirds with the previous value on same column on the basis on datetime column.
The above is the sample ss of the data. How can i achive this?
- Anonymous3 years ago
Hi sarvesh23p ,
Please try this code to create a measure.
Open Diff = VAR _Previous_Datetime = CALCULATE ( MAX ( 'Table'[Datetime] ), FILTER ( ALL ( 'Table' ), 'Table'[Datetime] < MAX ( 'Table'[Datetime] ) ) ) VAR _Previous_value = CALCULATE ( SUM ( 'Table'[Open] ), FILTER ( ALL ( 'Table' ), 'Table'[Datetime] = _Previous_Datetime ) ) VAR _Current_value = CALCULATE ( SUM ( 'Table'[Open] ) ) RETURN _Current_value - _Previous_valueMy Sample:
Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- AnonymousNot applicable
Hi sarvesh23p ,
Please try this code to create a measure.
Open Diff = VAR _Previous_Datetime = CALCULATE ( MAX ( 'Table'[Datetime] ), FILTER ( ALL ( 'Table' ), 'Table'[Datetime] < MAX ( 'Table'[Datetime] ) ) ) VAR _Previous_value = CALCULATE ( SUM ( 'Table'[Open] ), FILTER ( ALL ( 'Table' ), 'Table'[Datetime] = _Previous_Datetime ) ) VAR _Current_value = CALCULATE ( SUM ( 'Table'[Open] ) ) RETURN _Current_value - _Previous_valueMy Sample:
Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.