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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

GROUP BY logic

Hi,

 

Consider the sample data below.

 

Screenshot_49.png

 

FG - Finished Good

RM - Raw Material

I want to calculate the yield value for a finished good (it's already calculated in the table above for understanding purpose)

The logic for calculating it is - FG Qty / (RM Qty with maximum RM Cost)

Eg: For FG1, raw material with max cost is RM3. So its yield value will be 1000/300.

 

I'm facing difficulty to write a DAX measure for yield.

Please provide suggestions if any.

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Perhaps something like:

Yield = 
VAR maxRMCost = MAX(Yields[RM Cost])
VAR tmpTable = FILTER(Yields,[RM Cost]=maxRMCost)
RETURN SUMX(tmpTable,[FG Qty]) / SUMX(tmpTable,[RM Qty])

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Can you mark the proper answer as a solution please?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Community Champion
Community Champion

Perhaps something like:

Yield = 
VAR maxRMCost = MAX(Yields[RM Cost])
VAR tmpTable = FILTER(Yields,[RM Cost]=maxRMCost)
RETURN SUMX(tmpTable,[FG Qty]) / SUMX(tmpTable,[RM Qty])

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Anonymous

 

Another way.. to have a column like

 

Yield =
VAR maxCost =
    CALCULATE ( MAX ( Table1[RM Cost] ), ALLEXCEPT ( Table1, Table1[Batch] ) )
RETURN
    Table1[FG Qty]
        / CALCULATE (
            SUM ( [RM Qty] ),
            FILTER ( ALLEXCEPT ( Table1, Table1[Batch] ), Table1[RM Cost] = maxCost )
        )

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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.