Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculate period

Hallo everyone,   If I have this table and I want to calculate for each ID the duration between the end time and the start time of the next event.    In the column marked in green is the value I ...
  • v-xicai's avatar
    6 years ago

    Hi Anonymous ,

     

    You may create measure like DAX below.

     

     

    DiffTime= 
    Var _ThisTime = SELECTEDVALUE(Table1[Event time])
    
    Var _SecondTime= CALCULATE(MIN(Table1[Start time]),FILTER(ALLSELECTED(Table1), Table1[ID] =MAX(Table1[ID]) && Table1[Event time] >_ThisTime ))
    
    Return
    
    DATEDIFF(_ThisTime , _SecondTime, MINUTE )

     

     

    Best Regards,

    Amy 

     

    Community Support Team _ Amy

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.