cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Helper III

## Weighted Average of two measures

I have two measures Rawqty used and raw material usedweight by warehouse.  They work great when I have warehouse and Part_0 in each row.  However I want to remove those field and only have Raw Material and RawMaterialUsedWeightbyWarehousepartcode measure showing.

Basically just a total of the Rawmaterialusedweightbywarehousepartcode column.  Since teh qtyused is a measure that averages based on part_0 and warehouse, once these columns are removed my data calculates incorrrectly.

1 ACCEPTED SOLUTION
Impactful Individual

Ok I lied, I don't want to try to understand that formula. Can you try:

NewMeasure = SUMX(SUMMARIZE('Table', 'Table'[Warehouse], 'Table'[part_0], "num", [RawMaterialUsedweightbywarehousepartcode]), [num])

?

9 REPLIES 9
Responsive Resident

To retain the row context without explicitly showing the rows in the table, you can use one of the "X" functions.  In your case, if you want to show the total, you would use SUMX and tell it to iterate over the Part # while calculating RawMaterialUsed...

"The fields referenced in SUMX do NOT have to be present in your [table]...I like to think of it as a stack of invisible cells underneath each pivot cell that you can see, and SUMX is rolling up a lot of logic across those invisible cells to return a simple number to the top cell you can see."

Community Champion

Can you share the sample data and the final output you desire.

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!
Helper III

The screen shot in the orginal attachement had the sample data that has the correct amounts when broken out by warehouse and part_0.

I expect the result to be 67,344 which is the sum of the last column.

However when I remove Part_0 and ware house my totals change, due to measure qty used2 being a calculated average

Impactful Individual

The formulas you're currently using for the measures would be useful for understanding I think. Although conceptually, I think @chrisu is right about the solution.

Helper III
Rawqtyused2=calculate(average(Rc_Full_Level_Recipes[Rawqtyused]) RawMaterialUsedweightbywarehousepartcode = IF([RawQTYUsed2]=1,CALCULATE(SUM(RC_Daily_Sales_Report_Invoice_Line_Detail[Invoice_Qty]),FILTER(ALL(RC_FULL_LEVEL_RECIPES[Warehouse_0]),COUNTROWS(FILTER(VALUES(RC_Daily_Sales_Report_Invoice_Line_Detail),RC_Daily_Sales_Report_Invoice_Line_Detail[Warehouse]=RC_FULL_LEVEL_RECIPES[Warehouse_0]))>0),FILTER(ALL(RC_FULL_LEVEL_RECIPES[Part_0]),COUNTROWS(FILTER(VALUES(RC_Daily_Sales_Report_Invoice_Line_Detail),RC_Daily_Sales_Report_Invoice_Line_Detail[PART_CODE]=RC_FULL_LEVEL_RECIPES[Part_0]))>0))*[RawQTYUsed2],CALCULATE(SUM(RC_Daily_Sales_Report_Invoice_Line_Detail[Weight]),FILTER(ALL(RC_FULL_LEVEL_RECIPES[Warehouse_0]),COUNTROWS(FILTER(VALUES(RC_Daily_Sales_Report_Invoice_Line_Detail),RC_Daily_Sales_Report_Invoice_Line_Detail[Warehouse]=RC_FULL_LEVEL_RECIPES[Warehouse_0]))>0),FILTER(ALL(RC_FULL_LEVEL_RECIPES[Part_0]),COUNTROWS(FILTER(VALUES(RC_Daily_Sales_Report_Invoice_Line_Detail),RC_Daily_Sales_Report_Invoice_Line_Detail[PART_CODE]=RC_FULL_LEVEL_RECIPES[Part_0]))>0))*[RawQTYUsed2])
Impactful Individual

Ok I lied, I don't want to try to understand that formula. Can you try:

NewMeasure = SUMX(SUMMARIZE('Table', 'Table'[Warehouse], 'Table'[part_0], "num", [RawMaterialUsedweightbywarehousepartcode]), [num])

?

Helper III

Any thoughts on ignoring a customer filter using that example.

So in the example below we use 83,000,000 lbs of a product as a company.  But when we select a specific customer it filters correctly to show that customer uses 108,969.  I would like to have a second meaasure in that table that when a customer it still shows to total company usage. This way we can quickly say the customer uses 108,969 or the 83,000,000 lbs.

Impactful Individual

Just wrap the measure I gave above in a calculate with an ALL on the filter you'd like to ignore.

SecondMeasure = CALCULATE([NewMeasure], ALL('Table'[Customer]))

Helper III

that doesnt seem to work. Everytime I select a customer I get a different "all" number for the same raw material.

I have also tryed using several different variations of all between the three tables still with no luck.

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Power BI Monthly Update - May 2024

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

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors