Forum Discussion

Taro_Gulat's avatar
Taro_Gulat
Regular Visitor
1 year ago
Solved

Timestamp difference average

Hi all,    I am having a difficulty in calculating an average value for the below scenario:   in the above mentioned table i need to calculate always starting from step 2 (step 1 always exc...
  • ryan_mayu's avatar
    1 year ago

    Taro_Gulat 

    you can try this

     

    Measure =
    var a=minx(FILTER('Table','Table'[Item]="A"),'Table'[Date])
    var b=minx(FILTER('Table','Table'[Item]="B"),'Table'[Date])
    return ABS(DATEDIFF(a,b,MINUTE))
     
    Measure 2 = averagex(VALUES('Table'[Steps]),[Measure])
     
    then unselect step 1 in the table visual filter
    pls see the attachment below
     
     
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Taro_Gulat 

     

    Thanks for the reply from FarhanJeelani and ryan_mayu .

     

    Taro_Gulat , Please refer to the following test.

     

    Create two measures as follow

     

    Min = CALCULATE(MIN('Table'[Date]), ALL('Table'), 'Table'[Steps] <> "Step1", 'Table'[Steps] = MAX('Table'[Steps]), 'Table'[Item] = MAX('Table'[Item]))

     

     

     

    Average = 
    VAR _minA = MINX(FILTER('Table', 'Table'[Steps] = MAX('Table'[Steps]) && 'Table'[Item] = "A"), [Min])
    VAR _minB = MINX(FILTER('Table', 'Table'[Steps] = MAX('Table'[Steps]) && 'Table'[Item] = "B"), [Min])
    VAR _DateDiff = IF(MAX([Steps]) <> "Step1", ABS(DATEDIFF(_minB, _minA, MINUTE)))
    VAR _count = CALCULATE(DISTINCTCOUNT('Table'[Steps]), 'Table'[Steps] <> "Step1")
    VAR _result = DIVIDE(_DateDiff, _count)
    RETURN
    _result

     

     

    Output:

     

    Best Regards,
    Yulia Xu

     

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