Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
rsbin
Community Champion
Community Champion

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 Week, and Hour.

ID Hour Date Day
1 8 12-Sep Monday
2 8 12-Sep Monday
3 9 12-Sep Monday
4 9 12-Sep Monday
5 9 12-Sep Monday
6 10 12-Sep Monday
7 10 12-Sep Monday
8 11 12-Sep Monday
9 12 12-Sep Monday
10 8 5-Sep Monday
11 7 5-Sep Monday
12 9 5-Sep Monday
13 9 5-Sep Monday
14 13 5-Sep Monday
15 14 5-Sep Monday
16 14 5-Sep Monday
17 15 5-Sep Monday

I need to calculate the average of the count of work orders completed by both day of week and hour of the day.

Hoping one of you can help set me straight as to how best to set up my Measure so I can create a Matrix visual similar to this (please disregard the color formatting):

rsbin_0-1663010361220.png

Thanks in advance and Best Regards,

1 ACCEPTED SOLUTION
bcdobbs
Community Champion
Community Champion

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.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

4 REPLIES 4
bcdobbs
Community Champion
Community Champion

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.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
rsbin
Community Champion
Community Champion

@bcdobbs ,

Thanks very much for the response Ben.

I was stuck at how best to create the virtual table.  I ended up creating an actual Calculated Table, but I was certain there was a more effective / efficienct way to do this.  I think you got me over the bump I was having.

 

Thanks again and Best Regards,

bcdobbs
Community Champion
Community Champion

I'd be interested to lookat the performance comparison between the two especially if your actual data is very large. Moving the table variable over into a calculated table with a date dimension and an hour dimension for example filtering both effectively would act as a pre aggregated table.

 

Glad that helped though.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
bcdobbs
Community Champion
Community Champion

If you need it to calculate an overall average including zero hours you'd need to cross join your table variable so you have every combination of date/hour.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.