Forum Discussion

MichaelBalla's avatar
MichaelBalla
New Member
5 years ago
Solved

DATEDIFF by group

I have a dataset as shown below that I would like to calculate the average duration of each type based on the difference between the start and end times of each group.   Sample Data Group Type...
  • v-xulin-mstf's avatar
    5 years ago

    Hi MichaelBalla

     

    Create column as:

    Duration = 
    CALCULATE(DATEDIFF(MAX('Log'[StartTime]),MAX('Log'[EndTime]),SECOND))

    Create a measure as:

    PartFabTime = 
    AVERAGEX(
        FILTER(
            ALL('Log'),
            'Log'[Type]=MAX('Log'[Type])
        ),
        'Log'[Duration]
    )

    Here is the output:

     

    If you still have some question, please don't hesitate to let me known.‌‌

     

    Best Regards,

    Link

     

    Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution. Really appreciate!