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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Thigs
Helper IV
Helper IV

Weighted average but filter?

I've look at the other weighted average posts and still a little confused so hoping for some help. I have a large data set with SKUs, a metric called pallet factor (how much of that particular SKU fits on a pallet, ex - 54 cases), and a quantity shipped for the month (ex - 32 cases of this SKU shipped in December). 

 

I need to create a weighted average using the amount of times shipped x the pallet factor, so I'm weighting the pallet factor. 

 

BUT I need to make it able to be filtered. So if I select the clothes department, it changes the weights to only the clothes department. If it's the pet department, only the pet department, and if its both, then both are included in the weights. 

Here is my formula so far - 

Weighted PF = 

VAR _Table = summarize('Order Data','Order Data'[SKU], "Quantity New", sum('Order Data'[Quantity]), "PF", AVERAGE('Pallet Factor'[PF]))

RETURN
SUMX(_Table, ([Quantity New] * [PF])/sum([Quantity New]))

It is just returning "NaN", so clearly I'm doing something wrong. Are you able to use two different tables in a summarize formula? I've never tried that before. The tables are indirectly related through a fact table. 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Thigs , try like

Weighted PF =
VAR _Table = summarize('Order Data','Order Data'[SKU], "Quantity New", sum('Order Data'[Quantity]), "PF", AVERAGE('Pallet Factor'[PF]))
RETURN
divide( SUMX(_Table, [Quantity New] * [PF]),SUMX(_Table,[Quantity New]))

 

or

 

Weighted PF =
VAR _Table = summarize('Order Data','Order Data'[SKU], "Quantity New", sum('Order Data'[Quantity]), "PF", AVERAGE('Pallet Factor'[PF]))
RETURN
SUMX(_Table, divide([Quantity New] * [PF],[Quantity New]))

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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Thigs , try like

Weighted PF =
VAR _Table = summarize('Order Data','Order Data'[SKU], "Quantity New", sum('Order Data'[Quantity]), "PF", AVERAGE('Pallet Factor'[PF]))
RETURN
divide( SUMX(_Table, [Quantity New] * [PF]),SUMX(_Table,[Quantity New]))

 

or

 

Weighted PF =
VAR _Table = summarize('Order Data','Order Data'[SKU], "Quantity New", sum('Order Data'[Quantity]), "PF", AVERAGE('Pallet Factor'[PF]))
RETURN
SUMX(_Table, divide([Quantity New] * [PF],[Quantity New]))

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

Worked beautifully, thanks a bunch!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.