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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
RickBickens
Helper I
Helper I

Adding/Calculating Columns in a Table created with a Measure

Hi there,

 

I am working on trying to create a table within a measure, which has multiple columns which are subsequently calculated within the measure and am having trouble within the generated table referencing the other columns for calculations. 

 

The reason I am building a table within a measure to perform these calculations is some depend on values passed from measures and I want the calculations to be dynamic. I built the calculations in calculated columns previously but those do not recalculate/adjust when the parameters are changed. 

 

My formula for the measure is:

 

Measure First Shift Util = 
var table1 = ADDCOLUMNS(
SUMMARIZE(Order_Data,Order_Data[FIXED_DATE], "Lines", COUNTROWS(Order_Data)),

"Hours_Required", [Lines] / 'SummarizedDays'[Design Lines per Hour], 

"Shifts_Required", CEILING([Hours_Required]/'HoursPerShift'[HoursPerShift Value],'HoursPerShift'[HoursPerShift Value]),

"First_Shift_Utilization", If([Shifts_Required] = 1, [Lines]/(HoursPerShift[HoursPerShift Value]*[Design Lines per Hour]),1))

return AVERAGEX(table1,[First_Shift_Utilization])

 


Currently I am able to reference [Lines] within the measure but the references to the [Hours_Required], [Shifts_Required], and [First_Shift_Utilization] cannot be found or may not be used in this expression. 

RickBickens_0-1663776603462.png

Any help/suggestions are greatly appreciated.

1 ACCEPTED SOLUTION
RickBickens
Helper I
Helper I

I figured out that the measure can't reference the columns while they are being created in that format.
In order to build the table I was trying to create in the measure, and have the subsequent columns calculate with values present in the other columns, I needed to do the following:

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

This allowed the columns to be added one-by-one and then the columns could reference other columns addde in earlier ADDCOLUMNS() operations.

View solution in original post

1 REPLY 1
RickBickens
Helper I
Helper I

I figured out that the measure can't reference the columns while they are being created in that format.
In order to build the table I was trying to create in the measure, and have the subsequent columns calculate with values present in the other columns, I needed to do the following:

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

This allowed the columns to be added one-by-one and then the columns could reference other columns addde in earlier ADDCOLUMNS() operations.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors