Forum Discussion
jobf
2 years agoHelper II
Difference between several dates in the same column
Hello. I need to calculate the difference between several dates in the same column. For example: Field Date P1 01/01/2024 P1 01/03/2024 P1 01/06/2024 P1 01/11/2024 P2 02/02/...
- Anonymous2 years ago
Hi jobf
Thanks for the reply from samratpbi .
jobf , you can try the following measure:
Difference = VAR _Previous = MAX('Table'[Date]) VAR _PreviousRowDate = CALCULATE( MAX('Table'[Date]), FILTER( ALLEXCEPT('Table', 'Table'[Field]), 'Table'[Date] < _Previous ) ) RETURN IF( ISBLANK(_PreviousRowDate), 0, MAX([Date]) - _PreviousRowDate )Output:
Best Regards,
Yulia XuIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
samratpbi
2 years agoSuper User
Hi, in addition, just noticed you are resetting the calculation based on the field. Hence little modification on the previous calculation which should be like below:
Versus previous =
IF(
[Field ] <> PREVIOUS([Field ]),
0,
IF(
PREVIOUS([Date]) = BLANK(), 0,
[Date] - PREVIOUS([Date])
)
)
If this helps to resolves your problem, then please mark it as solution, Thanks