Forum Discussion
Previous value calculated column
- Anonymous3 years ago
Hi Anonymous ,
Please try:Previous Value = VAR _Cur_Date = 'Sheet1'[Date] VAR _Pre_Date = CALCULATE ( MAX ( 'Sheet1'[Date] ), FILTER ( ALL ( 'Sheet1' ), 'Sheet1'[Date] < _Cur_Date ) ) VAR _Pre_Value = CALCULATE ( MAX ( 'Sheet1'[Real h_M] ), FILTER ( ALL ( 'Sheet1' ), 'Sheet1'[Date] = _Pre_Date ) ) RETURN _Pre_ValueBest Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
Hi Anonymous ,
Thanks for the solution, it works for what I want 🙂
however, I did some stress tests with repetetive days and it give wrong values.
any solution to avoid this?
thanks anyway for your help 🙂
regards,
Abdel.
Hi Anonymous ,
The problem is that the date column is not unique. Try to add an index column to the Power Query Eidtor. And use like:
Previous Value =
VAR _Cur_Index = 'Sheet1'[Index]
VAR _Pre_Index =
CALCULATE (
MAX ( 'Sheet1'[Index] ),
FILTER ( ALL ( 'Sheet1' ), 'Sheet1'[Index] < _Cur_Index )
)
VAR _Pre_Value =
CALCULATE (
MAX ( 'Sheet1'[Real h_M] ),
FILTER ( ALL ( 'Sheet1' ), 'Sheet1'[Index] = _Pre_Index )
)
RETURN
_Pre_Value
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data