Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Days Difference between work order previous open date and last work order closed date

Hi All,   I have a query as i have a table where i wish to create a difference between the same serial number's first Work order closed and second Work order opened date as Days Diff so that i can ...
  • v-yadongf-msft's avatar
    4 years ago

    Hi Anonymous ,

     

    Please add an index column in Power Query:

     

    Then please try following DAX:

    Days difference = 
    var cur_index = 'Table'[Index]
    var pre_index = cur_index+1
    var diffe = CALCULATE(
        MAX('Table'[CreateDate]),
        FILTER('Table','Table'[Index] = pre_index && 'Table'[Serial Number] = EARLIER('Table'[Serial Number])))
    return
    DATEDIFF([ClosedOn],diffe,DAY)

     

    If I misunderstand your demands, please feel free to contact us in time.

     

    Best regards,

    Yadong Fang

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