Forum Discussion

phyten's avatar
phyten
Icon for Helper I rankHelper I
9 years ago
Solved

Calculate time between to states with different rows

I want to calculate the time difference between two states. Not sure if it is import to mention: Same state changes can occur more than once: f.e. key: A  "in development" -> "ready" ha...
  • phyten's avatar
    phyten
    9 years ago

    Thank you for alle the suggestions and answers.

    I only tested one of the solutions until now since I have limited time.  I will look further into it after the 9th of january. (yey holidays)

     

    I had to edit austinsense answer a bit but it seems to work now.

    diff = VAR vKEY = timetest[key]
     VAR vINDEX = timetest[Index]
    
    RETURN
    
    DATEDIFF(
    CALCULATE( VALUES(timetest[Date]),
         FILTER( ALL(timetest),
              timetest[key] = vKEY &&
              timetest[Index] = (vINDEX - 1)
         )
     ),timetest[Date],DAY)

    Things I changed. Had to add timediff in order to calculated the timeperiod else it would have substracted two dates resulting in another date.  I had to switch the minuend and the subtrahend.