Forum Discussion
Anonymous
5 years agoNot applicable
Subtracting two rows
I am working on a data set, which includes information for about around 30 meters. These meters acted like counters (read data, then add the values on the previous ones meaning all the time increasin...
- 5 years ago
Hello @ehsanbh ,
Sorry to respond late.
For question 1:
If you have about 25-30 similar parameters in this dataset, you might consider creating a measure instead of a calculated column to do this because the computed column will occupy the actual memory. The measure will be as this:
Measure = VAR a = SUM ( 'Table'[Index] ) - 1 VAR previous = CALCULATE ( MAX ( 'Table'[EL,AX12(MWh)] ), FILTER ( ALL ( 'Table' ), 'Table'[Index] = a ) ) RETURN IF ( ISBLANK ( previous ), 0, SUM ( 'Table'[EL,AX12(MWh)] ) - previous )For question 2:
Calculated column:
Column = VAR _lastrow = CALCULATE ( SUM ( 'Table'[EL,AX12(MWh)] ), FILTER ( ALL ( 'Table' ), 'Table'[Index] = EARLIER ( 'Table'[Index] ) - 1 ) ) RETURN IF ( ISBLANK ( _lastrow ), 0, [EL,AX12(MWh)] - _lastrow )The measure is as above. Here is the result by using the measure:
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.
Syndicate_Admin
3 years agoAdministrator
Thank you very much, very good code. It is much appreciated.