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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
RickBickens
Helper I
Helper I

Return Average of a Column from a Table Generated by a Measure

Hi there,

 

I have a measure which creates a table in which I need the average of one of the columns. I am generating the table in a measure so the whole table can be re-evaluated when certain parameters are changed. I am having trouble calculating the average of the last column of the table and returning that value.
The measure is as follows:

RickBickens_2-1664221762386.png

 

Measure First Shift Util = 
var HrsPerShift = HoursPerShift[HoursPerShift Value]
var DesignLinesPerHour = 'SummarizedDays'[Design Lines per Hour]
var table1 = ADDCOLUMNS(ADDCOLUMNS(ADDCOLUMNS(SUMMARIZE(Order_Data,Order_Data[FIXED_DATE], "Lines", COUNTROWS(Order_Data)), "Hours_Required", [Lines] / DesignLinesPerHour), "Shifts_Required", ROUNDUP([Hours_Required]/HrsPerShift,0)),"First_Shift_Utilization", If([Shifts_Required] = 1, [Lines]/(HrsPerShift*DesignLinesPerHour),1))

return AVERAGE([First_Shift_Utilization])

 

I have other measures that filter the data for days when there are 2 shifts per day, 3 shifts per day, etc. as well that I will need to return the average of the utilization column created of the table created by the measure. 

I've tried using AVERAGEX instead of AVERAGE (example below) but do not get the correct value when I do so due to how AVERAGEX calculates. 

RickBickens_3-1664221800990.png

 

Measure First Shift Util = 
var HrsPerShift = HoursPerShift[HoursPerShift Value]
var DesignLinesPerHour = 'SummarizedDays'[Design Lines per Hour]
var table1 = ADDCOLUMNS(ADDCOLUMNS(ADDCOLUMNS(SUMMARIZE(Order_Data,Order_Data[FIXED_DATE], "Lines", COUNTROWS(Order_Data)), "Hours_Required", [Lines] / DesignLinesPerHour), "Shifts_Required", ROUNDUP([Hours_Required]/HrsPerShift,0)),"First_Shift_Utilization", If([Shifts_Required] = 1, [Lines]/(HrsPerShift*DesignLinesPerHour),1))

return AVERAGEX(table1,[First_Shift_Utilization])

 

 

I used these measures to create tables to compare against, so I know the table creation part of the measure is populating how I expect, my issue is just returning the average of the "First_Shift_Utilization" column.

 

Thanks!
 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@RickBickens If table1 returns the correct values per row, then AVERAGEX should work. What are you getting versus what you expect? Can you post sample source data? Do you perhaps need to FILTER your table1 variable in your AVERAGEX?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

@RickBickens If table1 returns the correct values per row, then AVERAGEX should work. What are you getting versus what you expect? Can you post sample source data? Do you perhaps need to FILTER your table1 variable in your AVERAGEX?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thanks for confirming AVERAGEX is the way to go to achieve this. I dug a bit more and have realized that it was the effect of one of my "Filters on all Pages" that was causing the discrepancy.

@RickBickens Sounds good. In the future you can use CONCATENATEX in place of your AVERAGEX or similar X aggregator to view your intermediary table and this may help you troubleshoot.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors