cancel
Showing results for
Did you mean:
Highlighted
Frequent Visitor

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

Accepted Solutions
Highlighted
Community Support

## Re: DAX: Weighted Average Prices From Two Tables

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.
3 REPLIES 3
Highlighted
Super User IX

## Re: DAX: Weighted Average Prices From Two Tables

@KTTTTT , try Like

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

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Highlighted
Frequent Visitor

## Re: DAX: Weighted Average Prices From Two Tables

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

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

 WeekDate Retail Price Qty Sold 3/24/2019 \$162.99 0 3/25/2019 \$162.99 1 3/26/2019 \$162.99 2 3/27/2019 \$162.99 2 3/28/2019 \$159.99 0 3/29/2019 \$194.99 1 3/30/2019 \$194.99 0

Thanks again for the help.

Highlighted
Community Support

## Re: DAX: Weighted Average Prices From Two Tables

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.

Announcements

#### Microsoft Ignite

This will be a conference that you do not want to miss!

#### Get Ready for Power BI Dev Camp

Don't miss the Power BI Dev Camp this week!

#### August Community Highlights

Check out a full recap of the month!

#### August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

#### Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors