简体   繁体   中英

Calculate Daily Average Sales for top 3 products based on multiple conditions

I have an excel product sales table looking like this (last column is empty, i've just populated the result I'm looking to calculate):

Date Sales Retailer ProductName ProductType Top 3 daily AVG Sales
01/01/2021 1000 Retailer 1 Product 1 Mobile 2100
01/01/2021 2000 Retailer 1 Product 2 Desktop
01/01/2021 700 Retailer 1 Product 3 Desktop
01/01/2021 1250 Retailer 1 Product 4 Mobile 2100
01/01/2021 2200 Retailer 1 Product 5 Mobile 2100
01/01/2021 1700 Retailer 1 Product 6 Desktop
01/01/2021 2700 Retailer 1 Product 7 Mobile 2100
01/01/2021 1400 Retailer 1 Product 8 Mobile 2100
01/01/2021 1200 Retailer 1 Product 9 Desktop
01/01/2021 1650 Retailer 1 Product 10 Desktop
01/01/2021 1200 Retailer 2 Product 1 Mobile
01/01/2021 1000 Retailer 2 Product 2 Desktop
01/01/2021 600 Retailer 2 Product 3 Desktop
01/01/2021 2250 Retailer 2 Product 4 Mobile
01/01/2021 1450 Retailer 2 Product 5 Mobile
01/01/2021 1600 Retailer 2 Product 6 Desktop
01/01/2021 1700 Retailer 2 Product 7 Mobile
01/01/2021 1800 Retailer 2 Product 8 Mobile
01/01/2021 1300 Retailer 2 Product 9 Desktop
01/01/2021 1100 Retailer 2 Product 10 Desktop
01/02/2021 1000 Retailer 1 Product 1 Mobile
01/02/2021 2000 Retailer 1 Product 2 Desktop
01/02/2021 700 Retailer 1 Product 3 Desktop
01/02/2021 1250 Retailer 1 Product 4 Mobile
01/02/2021 2200 Retailer 1 Product 5 Mobile
01/02/2021 1700 Retailer 1 Product 6 Desktop
01/02/2021 2700 Retailer 1 Product 7 Mobile
01/02/2021 1400 Retailer 1 Product 8 Mobile
01/02/2021 1200 Retailer 1 Product 9 Desktop
01/02/2021 1650 Retailer 1 Product 10 Desktop
01/02/2021 1200 Retailer 2 Product 1 Mobile
01/02/2021 1000 Retailer 2 Product 2 Desktop
01/02/2021 600 Retailer 2 Product 3 Desktop
01/02/2021 2250 Retailer 2 Product 4 Mobile
01/02/2021 1450 Retailer 2 Product 5 Mobile
01/02/2021 1600 Retailer 2 Product 6 Desktop
01/02/2021 1700 Retailer 2 Product 7 Mobile
01/02/2021 1800 Retailer 2 Product 8 Mobile
01/02/2021 1300 Retailer 2 Product 9 Desktop
01/02/2021 1100 Retailer 2 Product 10 Desktop

In the Top 3 daily AVG Sales column I'm looking to write a formula that calculates the average top 3 sales for each day per Retailer and Product Type. So, if date is 01/01/2021 and Retailer is Retailer 1 and ProductType is Mobile, find the top 3 sales and average them => (2200+2700+1400)/3 = 2100

Appreciate any help with this.

You can try-

=AVERAGE(INDEX(SORT(FILTER($B$3:$B$42,($A$3:$A$42=A3)*($C$3:$C$42=C3)*($E$3:$E$42=E3)),,-1),{1,2,3}))

Edit: Try below array formula for non O365 excels. Must be enters nu CTRL+SHIFT+ENTER .

=AVERAGE(LARGE(IF(($A$2:$A$42=A2)*($C$2:$C$42=C2)*($E$2:$E$42=E2),$B$2:$B$42,""),{1,2,3}))

Press CTRL + SHIFT + ENTER to evaluate the formula as it is an array formula.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM