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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
wenchi
Helper I
Helper I

weighted average calculation with a twist

We have a fact table stores weekly data at store and brand with quantity and unit price. The users need to obtain the volume weighted average price by taking the lates week unit price weighted by the entire selected period quantity at store\brand level. For example, if the user choose week 50 to week 60 time span, the weighted average price is calculated with total volume of that time frame apply with week 60th store\brand price. Since Dax is not supported to create dynamic calculate table ( I thought I can create a dynamic table to store latest price for calculation, but i was wrong), I am kind of stuck to get it calculate correctly. Below are some sample data with calculation based on different weeks selection. Any helps are appreciated. Thanks.

wenchi_0-1599585326031.png

 

5 REPLIES 5
wenchi
Helper I
Helper I

I figure it out how to get it to work. with summarized followed by addcomoums, i get the correct number.

Hi Wenchi,

 

Could you share your solution please? and i suppose you mean AddColumns?

 

Thanks

amitchandak
Super User
Super User

@wenchi , if not resolved, Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
dedelman_clng
Community Champion
Community Champion

Hi @wenchi  - 

 

I'm able to get your desired results for the 1 and 2 week tables showing store and brand, but I'm uncertain as to how the average per brand is calculated.  Try this for the Latest Price and Extended Price, and let me know how VWA should be calculated.

 

 

Latest Price = var __lDate = LASTNONBLANK(WAvg[WE Date], MIN(WAvg[Price]))
return
CALCULATE(MIN(WAvg[Price]), __lDate)

Ext = CALCULATE(SUM(WAvg[Qty]) * [Latest Price])

 

 

Hope this helps

David

I poked around a little more and think I figured out VWA

 

VWA = var __LNB = LASTNONBLANK(WAvg[WE Date], MIN(WAvg[Qty]))
RETURN
CALCULATE(SUMX(WAvg, [Ext]) / SUM(WAvg[Qty]), __LNB)

 

Hope this helps

David

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.