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
Anonymous
Not applicable

DAX Weighted Averages

Hi everyone,

 

I'm trying to come up with a table in a report that has product line in the rows and weighted average product cost as the value. I have a dimension table with unique product number, product line (product lines are composed of many product numbers), and product cost, and a fact table (linked by unique product number) with unique product number and sales quantities. I want the weight of the weighted average to be set by sales quantities. Any help with the DAX formula would be much appreciated!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, I can't really upload the file because of proprietary data, but I figured out the code on my own. Basically, the DAX reads as follows:

WtdAvgCost = DIVIDE(
SUMX(SalesTable, SalesTable[SalesQuantity] * RELATED(ProductTable[ProductCost])),
SUMX(SalesTable, SalesTable[SalesQuantity]),
0)

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi, I can't really upload the file because of proprietary data, but I figured out the code on my own. Basically, the DAX reads as follows:

WtdAvgCost = DIVIDE(
SUMX(SalesTable, SalesTable[SalesQuantity] * RELATED(ProductTable[ProductCost])),
SUMX(SalesTable, SalesTable[SalesQuantity]),
0)
Ashish_Mathur
Super User
Super User

Hi,

 

Share the link from where i can download your file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.