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 Average Prices From Two Tables

Hi all,

 

I'd like to calculate the Weighted Average Retail Price which was derived from the 'Sales' and 'Price' tables.  My data model is like: 

  • a 'Product' table and a 'Date' table which contains one to many relationship with the 'Sales' and 'Price' Tables
  • Weighted Average Retail Price = Summation of ('Sales'[Total Unit Sold] * 'Price'[Retail Price]) / Sum('Sales'[Total Unit Sold])

 

Product Table
- ProductID

 

Date Table
- Date

 

 

Sales Table

- ProductID

- Date

- Unit Sold

 

Price Table

- ProductID

- Price Scrapped Date

- Retail Price

 

Can anyone help with this?  Thanks in advance.

 

1 ACCEPTED SOLUTION

@Anonymous 

 

You may refer to the measure below.

Measure =
DIVIDE (
    SUMX ( 'Table', 'Table'[Qty Sold] * 'Table'[Retail Price] ),
    SUM ( 'Table'[Qty Sold] )
)

 

 

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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , try Like

 

sumx(summarize('Product Table','Product Table'[ProductID],"_sum",sum('Sales'[Total Unit Sold]), "_avg",average('Price'[Retail Price])),divide(([_sum]*[_avg]),[_sum]))

 

Anonymous
Not applicable

Thanks amitchandak, I tried the formula but it only returns an Average instead of Weighted Average :(... 

Could you please help look into it?

 

Here's one example of Week 13.

  • Weighted Average Retail Price = $168.32 <-- this is the desired result for Week 13
    • In Excel formula = SUMPRODUCT(Retail Price, Qty Sold) / SUM(Qty Sold)
  • Average Retail Price = $171.70

 

WeekDateRetail PriceQty Sold

3/24/2019

$162.990
3/25/2019$162.991
3/26/2019$162.992
3/27/2019$162.992
3/28/2019$159.990
3/29/2019$194.991
3/30/2019$194.990

 

Thanks again for the help.

 

@Anonymous 

 

You may refer to the measure below.

Measure =
DIVIDE (
    SUMX ( 'Table', 'Table'[Qty Sold] * 'Table'[Retail Price] ),
    SUM ( 'Table'[Qty Sold] )
)

 

 

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

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