Forum Discussion

CoreX's avatar
CoreX
Regular Visitor
9 years ago
Solved

Create a SUM measure that sums conditionally

Hi all,   I'm new to Power BI and am really happy with some of the progress I'm making in visualizing my data, but I'm having some trouble getting the data to be presented in the way I need it.   ...
  • v-caliao-msft's avatar
    v-caliao-msft
    9 years ago

    CoreX,

     

    For this requiremnt, you can create two calculated table to achieve it.
    Table2 = SUMMARIZE(Table1,Table1[Part Number],Table1[Order Number],"TotalRunTime",CALCULATE(SUM(Table1[Run Time]),ALLEXCEPT(Table1,Table1[Part Number],Table1[Order Number])),"Output Quantity",CALCULATE(MAX(Table1[Output Quantity]),ALLEXCEPT(Table1,Table1[Part Number],Table1[Order Number])))

     

     

    Table3 = SUMMARIZE(Table2,Table2[Part Number],"TotalRunTime",CALCULATE(SUM(Table2[TotalRunTime]),ALLEXCEPT(Table2,Table2[Part Number])),"TotalOutputQuantity",CALCULATE(SUM(Table2[Output Quantity]),ALLEXCEPT(Table2,Table2[Part Number])))
    Average = Table3[TotalRunTime]/Table3[TotalOutputQuantity]

     

    Regards,

    Chalrie Liao