Forum Discussion

qwertzuiop's avatar
qwertzuiop
Advocate III
3 years ago
Solved

Date/Time Difference between ID

Dear Power BI Community   Following Task to solve: Let's assume this table:   We are looking for the date/time difference of an ID from the first to the last Occurence   Any ideas how to...
  • v-jianboli-msft's avatar
    v-jianboli-msft
    3 years ago

    Hi qwertzuiop ,

     

    Please try:

    TimeDiff_from_FirstTime_to_LastTime = 
    var _a = MAXX(FILTER(ALL('Table'),[ID]=SELECTEDVALUE('Table'[ID])&&[CheckOccurence]="FirstTime"),[Date/time])
    var _b = MAXX(FILTER(ALL('Table'),[ID]=SELECTEDVALUE('Table'[ID])&&[CheckOccurence]="LastTime"),[Date/time])
    return DATEDIFF(_a,_b,MINUTE)/(60*24)

    Final output:

    Best Regards,

    Jianbo Li

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