Forum Discussion
lightsaberluke
1 year agoRegular Visitor
Shift Data by one row down
Hi, I am trying to create a new measure where I have my data from another row just shifted down one. I found a video that used the following formula but it did not work: Previous Year = Calculate (...
- Anonymous1 year ago
Please try this:
Here's a sample:
Table:
Then add an index column in powerquery:
Next add a measure:
MEASURE = VAR _currentIndex = MAX ( 'Table'[Index] ) VAR _previousIndex = CALCULATE ( MAX ( 'Table'[Index] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] < _currentIndex ) ) RETURN CALCULATE ( SUM ( 'Table'[Values] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] = _previousIndex ) )The result is as follow:
Or if you have an date column:
You can try this measure without an index column:
MEASURE 2 = VAR _currentDate = MAX ( 'Table'[Date] ) VAR _PreviousDate = CALCULATE ( MAX ( 'Table'[Date] ), FILTER ( ALL ( 'Table' ), 'Table'[Date] < _currentDate ) ) RETURN CALCULATE ( SUM ( 'Table'[Values] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] = _PreviousDate ) )The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
1 year agoNot applicable
Please try this:
Here's a sample:
Table:
Then add an index column in powerquery:
Next add a measure:
MEASURE =
VAR _currentIndex =
MAX ( 'Table'[Index] )
VAR _previousIndex =
CALCULATE (
MAX ( 'Table'[Index] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] < _currentIndex )
)
RETURN
CALCULATE (
SUM ( 'Table'[Values] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Index] = _previousIndex )
)
The result is as follow:
Or if you have an date column:
You can try this measure without an index column:
MEASURE 2 =
VAR _currentDate =
MAX ( 'Table'[Date] )
VAR _PreviousDate =
CALCULATE (
MAX ( 'Table'[Date] ),
FILTER ( ALL ( 'Table' ), 'Table'[Date] < _currentDate )
)
RETURN
CALCULATE (
SUM ( 'Table'[Values] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] = _PreviousDate )
)
The result is as follow:
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.