Forum Discussion

rsbin's avatar
rsbin
Community Champion
3 years ago
Solved

Help with AVERAGEX

Good Afternoon, Trying to gain a better understanding of the AVERAGEX Function. My scenario is as follows:  I have WorkOrders completed throughout the day.  My Fact Table includes Date, Day of We...
  • bcdobbs's avatar
    3 years ago

    Try something like this:

    Average Count Per Day = 
    VAR DayHourGrain =
     ADDCOLUMNS (
        SUMMARIZE ( 
            Table1,
            Table1[Date],
            Table1[Day], 
            Table1[Hour] ),
        "@RowCount", CALCULATE ( COUNTROWS ( Table1 ) )
     )
    
    VAR Result = 
        AVERAGEX (
            DayHourGrain,
            [@RowCount]
        )
    
    RETURN Result

     

    Normally if you just needed an average by day I'd suggest a date table and just use that as the table aspect of AVERAGEX but here you need to build a distinct list of date/day/hour which you can then iterate over.

     

    Might be a more efficient way of doing it but I think this works.