Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

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 tab...
  • Anonymous's avatar
    Anonymous
    3 years ago

    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.