Formula to Caculate ave value of last 4 sales of one item?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,194
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I think this might be a little more complex that it sounds so I'll try explain all my problems and what i need.

I want a formula that can give me the ave of the last 4 sales of one item.

So in Sheets "Ave" Column D i have a list of SKU's so lets say i'm looking at row 4 for now,

So cell "D4" gives me the SKU "XYZ123"

Now in Sheet "Invoice" Column C are all my Sku's for each sale and in Column G the dates,
So I need to find the last 4 sales add then up and give me the average, however some might not have 4 sales in which case add up as many as there are, if theres none say "No Sales"
Please help if you can
Thanks
Tony
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
What column do you want to average?
 
Upvote 0
Ok, for 365, how about
Excel Formula:
=LET(Ary,SORT(FILTER(Invoice!C2:G100,Invoice!C2:C100=D4),5,-1),AVERAGE(INDEX(Ary,SEQUENCE(MIN(4,ROWS(Ary))),3)))
 
Upvote 0
This will work on earlier versions:

Excel Formula:
=IFERROR(AVERAGEIFS(Invoice!E2:E100,Invoice!C2:C100,D4,Invoice!G2:G100,">="&AGGREGATE(14,6,Invoice!G2:G100/(Invoice!C2:C100=D4),MIN(4,COUNTIF(Invoice!C2:C100,D4)))),"No Sales")
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top