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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
wallace13
Advocate II
Advocate II

Weighted Average of RTY

Hi all,

 

I've been trying to compute a weighted average of Roll Throughput Yield (RTY) using a DAX Measure, this would ideally compute at aggregations across multiple days and production lines.  I'm sure this is possible, but I haven't been able to make it work yet.  The particular problem I'm seeing is forcing the correct order of operations in the Measure.  I have tried using SUMMARIZE inside the measure to pre-aggregate the calculations as well as also working from the Quick Measure Weighted average, but I've not been able to make either method work.

The desired result is like in the Excel screenshot below:

wallace13_0-1641850181889.png

  1. FPY is pre-computed for each operation, line, day
  2. The products of those Line / Days FPY are calculated to determine the daily line RTY
    1. Ex. I2 = PRODUCT(H2:H4)
  3. The RTY are weighted by the TOTAL where KEY_STATION is TRUE
  4. Weighted RTY aggregations are computed based on filtering dynamically such as by date, month, year, line, etc.
    1. Ex. J2 =(I2*E4+I5*E7)/(E4+E7)
    2. Ex.  K2 = (I2*E4+I5*E7+I8*E10+I11*E13)/(E4 + E7 + E10 + E13)  

      I've added a table of the data above.

      DATE              LINE              OPERATION  PASS       TOTAL         KEY_STATION
      1-JanLine1A2525 
      1-JanLine1B2326 
      1-JanLine1C2025TRUE
      2-JanLine1A2025 
      2-JanLine1B2325 
      2-JanLine1C2424TRUE
      1-JanLine2A2327 
      1-JanLine2B2326 
      1-JanLine2C2024TRUE
      2-JanLine2A2025 
      2-JanLine2B2326 
      2-JanLine2C2123TRUE

      Update:  Added formula to examples.
1 ACCEPTED SOLUTION
wallace13
Advocate II
Advocate II

I was ultimately able to determine the right function.  You need to pre-calculate the table then group by and calculate.  That will ensure the correct order of operations.

 

RTY Summary = 

var opSummary = 
    SUMMARIZE(
        FTT
        ,[LINE],[OPERATIONNAME],[DATE],[Key Station]
        ,"FPY",DIVIDE(SUMX(FTT,[PASS]),SUMX(FTT,[TOTAL]),0)
        ,"TOTAL",sumx(ftt,[TOTAL])
        ,"KEY_TOTAL",sumx(FILTER(ftt,[Key Station]=True),[TOTAL])
    )

var lineSummary = 
    GROUPBY(opSummary,[LINE],[DATE]
        ,"RTY",PRODUCTX(CURRENTGROUP(),[FPY])
        ,"LINE_TOTAL",SUMX(CURRENTGROUP(),[KEY_TOTAL])
)

return 

CALCULATE(
    DIVIDE(
        SUMX(lineSummary,[RTY]*[LINE_TOTAL]),
        SUMX(lineSummary,[LINE_TOTAL])
    )
)

 

 

View solution in original post

3 REPLIES 3
wallace13
Advocate II
Advocate II

I was ultimately able to determine the right function.  You need to pre-calculate the table then group by and calculate.  That will ensure the correct order of operations.

 

RTY Summary = 

var opSummary = 
    SUMMARIZE(
        FTT
        ,[LINE],[OPERATIONNAME],[DATE],[Key Station]
        ,"FPY",DIVIDE(SUMX(FTT,[PASS]),SUMX(FTT,[TOTAL]),0)
        ,"TOTAL",sumx(ftt,[TOTAL])
        ,"KEY_TOTAL",sumx(FILTER(ftt,[Key Station]=True),[TOTAL])
    )

var lineSummary = 
    GROUPBY(opSummary,[LINE],[DATE]
        ,"RTY",PRODUCTX(CURRENTGROUP(),[FPY])
        ,"LINE_TOTAL",SUMX(CURRENTGROUP(),[KEY_TOTAL])
)

return 

CALCULATE(
    DIVIDE(
        SUMX(lineSummary,[RTY]*[LINE_TOTAL]),
        SUMX(lineSummary,[LINE_TOTAL])
    )
)

 

 

amitchandak
Super User
Super User

@wallace13 , How you have done calculations for I, J, and K are very clear. can you explain with an example 

I've added the formula examples now.  Thanks!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors