cancel
Showing results for
Did you mean:

## 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:

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-Jan Line1 A 25 25 1-Jan Line1 B 23 26 1-Jan Line1 C 20 25 TRUE 2-Jan Line1 A 20 25 2-Jan Line1 B 23 25 2-Jan Line1 C 24 24 TRUE 1-Jan Line2 A 23 27 1-Jan Line2 B 23 26 1-Jan Line2 C 20 24 TRUE 2-Jan Line2 A 20 25 2-Jan Line2 B 23 26 2-Jan Line2 C 21 23 TRUE

Update:  Added formula to examples.
1 ACCEPTED SOLUTION

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])
)
)``````

3 REPLIES 3

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])
)
)``````

Super User

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

New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

I've added the formula examples now.  Thanks!

Announcements

#### Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

#### Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

#### The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors