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

Trying to use AVERAGEIFS to create a weighting based on Month and Item Type

I am trying to create a weight for product attributes using: Price / Average Price of the Same Item Type in the Same Month. I have done the same calulations in excel using an AVERAGEIFS function in the denominator but cant seem to replicate the same results in Power BI.

 

My current column formula is: 

 

Weight = 'Sales'[Price] / CALCULATE(AVERAGE('Sales'[Price]), FILTER ( 'Sales', 'Sales'[Month-Year] = 'Sales'[Month-Year] && 'Sales'[Item Type] = 'Sales'[Item Type] ))
 
but this doesnt seem to be calculating the expected results.
 
Power BI Results
Item #Item TypeMonth-YearPriceWeight
80011January 201921500.2973
80022January 2019103041.4248
80031January 201978111.0801
80041January 201965400.9043
80052January 2019150072.0751
80061January 201949910.6901
80071January 201959890.8281
80081February 201990281.2484
80092February 201927840.3850
80102February 201947440.6560
80111February 201910780.1491
80122February 2019133861.8510
80131February 201998771.3658
80142March 201937640.5205
80152March 2019110241.5244

 

Excel Results

ABCDE
Item #Item TypeMonth-YearPriceWeight
80011Jan-1921500.3912
80022Jan-19103040.8142
80031Jan-1978111.4212
80041Jan-1965401.1899
80052Jan-19150071.1858
80061Jan-1949910.9081
80071Jan-1959891.0897
80081Feb-1990281.3554
80092Feb-1927840.3993
80102Feb-1947440.6805
80111Feb-1910780.1618
80122Feb-19133861.9201
80131Feb-1998771.4828
80142Mar-1937640.5091
80152Mar-19110241.4909

 

where the weight function is: = D2 / AVERAGEIFS($D:$D,$B:$B,B2,$C:$C,C2)

 

Any help would be greatly appreciated, thanks!

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

Please test this as I looked at relatively briefly.

The calculated column should be:

ChilliWeight = 'Sales'[Price] / CALCULATE(AVERAGE('Sales'[Price]), 
                                    FILTER ( 'Sales', 
                                             'Sales'[Month-Year] = EARLIER('Sales'[Month-Year]) && 
                                             'Sales'[Item Type] = EARLIER('Sales'[Item Type] )))

The reason the original code didn't work is that the denominator was 7231.8 for every row

 

View solution in original post

2 REPLIES 2
HotChilli
Super User
Super User

Please test this as I looked at relatively briefly.

The calculated column should be:

ChilliWeight = 'Sales'[Price] / CALCULATE(AVERAGE('Sales'[Price]), 
                                    FILTER ( 'Sales', 
                                             'Sales'[Month-Year] = EARLIER('Sales'[Month-Year]) && 
                                             'Sales'[Item Type] = EARLIER('Sales'[Item Type] )))

The reason the original code didn't work is that the denominator was 7231.8 for every row

 

Anonymous
Not applicable

This seems to have worked! Thank you very much!

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.