Forum Discussion

jobf's avatar
jobf
Helper II
2 years ago
Solved

Multiple differences between values ​​in the same column

I need to calculate the difference between dates in the same column. For example: Field Input Date P1 Enzow 2024/01/24 P1 Plut 2024/02/25 P1 Plut 2024/02/19 P1 Plut 2024/02/...
  • Irwan's avatar
    2 years ago

    hello jobf 

     

    please check if this accomodate your need.

    Difference =
    var _MinDate = MINX(FILTER('Table','Table'[Field]=EARLIER('Table'[Field])&&'Table'[Input]=EARLIER('Table'[Input])),'Table'[Date])
    var _PreviousDate =
    CALCULATE(
        MAX('Table'[Date]),
        ALL('Table'),
        OFFSET(-1,ORDERBY('Table'[Date]),PARTITIONBY('Table'[Field],'Table'[Input]))
    )
    Return
    IF(
        'Table'[Date]=_MinDate,
        BLANK(),
        'Table'[Date]-_PreviousDate
    )

     

    Hope this will help you.

    Thank you.