Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Averages Showing Wildly Incorrect Numbers

I am trying to find the average pickup and dropoff times for each client in our center to compare to the scheduled pickup/dropoff times for analysis. I have tried this a few different ways but the av...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi  Anonymous ,

    I created some data:

    I'm not very clear about what you mean by date average, whether it refers to the average of the minimum date and the maximum date (hh:mm:ss), if it's convenient, you can explain the logic of date average, we can help you better.

     

    Here are the steps you can follow:

    1. Create calculated column.

    If you want to get the average of the minimum and maximum dates after grouping (hh:mm:ss)

     

    AVG(hhmmss) =
    var _mindate=
    MINX(FILTER(ALL('Table'),'Table'[Group]=EARLIER('Table'[Group])),[Scheduled DropOff])
    var _maxdate=
    MAXX(FILTER(ALL('Table'),'Table'[Group]=EARLIER('Table'[Group])),[Scheduled DropOff])
    var _second=
    DATEDIFF(
        _mindate,_maxdate,SECOND)
    var _count=
    COUNTX(
      FILTER(ALL('Table'),'Table'[Group]=EARLIER('Table'[Group])),[Scheduled DropOff])
    var _avg=
    DIVIDE(
        _second,_count)
    RETURN
    TIME ( 0, 0, FLOOR ( _avg, 1 ) )

     

    If you want to get the average date between the minimum and maximum dates after grouping.

     

    AVG =
    var _mindate=
    MINX(FILTER(ALL('Table'),'Table'[Group]=EARLIER('Table'[Group])),[Scheduled DropOff])
    RETURN
    _mindate + [AVG(hhmmss)]

     

    2. Set the data format as follows.

    3. Result:

     

    Best Regards,

    Liu Yang

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