How to find most items with most recent date?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,691
Office Version
  1. 365
Platform
  1. Windows
I have a table with a record for each time I have purchased various products. I'd like to create a second table that has just one record for each item with columns for the number of times it was purchased, the average price, and the date of the most recent purchase. I have the first two, but am stuck on how to get the most recent date.

I would post a mini-sheet, but I am having trouble installing xl2bb on this new laptop.

Thanks
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Like this:
Book1
ABCDEFGH
1ProductPriceDateProductID#timesAvg $Most recent
2Product 1$25.0010/07/2023Product 13$24.0018/07/2023
3Product 2$23.0011/07/2023Product 23$17.3319/07/2023
4Product 3$25.0012/07/2023Product 33$19.6720/07/2023
5Product 4$4.0013/07/2023Product 43$4.3321/07/2023
6Product 1$24.0014/07/2023
7Product 2$4.0015/07/2023
8Product 3$21.0016/07/2023
9Product 4$6.0017/07/2023
10Product 1$23.0018/07/2023
11Product 2$25.0019/07/2023
12Product 3$13.0020/07/2023
13Product 4$3.0021/07/2023
Sheet1
Cell Formulas
RangeFormula
F2:F5F2=COUNTIF(A:A,E2)
G2:G5G2=AVERAGEIF(A:A,E2,B:B)
H2:H5H2=MAXIFS(C:C,A:A,E2)
 
Upvote 0
Solution
Perfect. I was using CountIfs and SumIfs (now replaced by AverageIfs), but stupidly did not think to try MaxIfs. 😒😢 I did a search, but all I found was array solutions.

Thank you!
Happy to help Jennifer, and thanks for the feedback 👍 😀
 
Upvote 0
I know you have a solution, but I wanted to show you an altercative with Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product", type text}, {"Price", Int64.Type}, {"Date", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Product"}, {{"Count", each Table.RowCount(_), Int64.Type}, {"Average Price", each List.Average([Price]), type nullable number}, {"Last Date", each List.Max([Date]), type nullable date}})
in
    #"Grouped Rows"

Book6
ABCDEFGH
1ProductPriceDateProductCountAverage PriceLast Date
2Product 1257/10/2023Product 13247/18/2023
3Product 2237/11/2023Product 2317.333333337/19/2023
4Product 3257/12/2023Product 3319.666666677/20/2023
5Product 447/13/2023Product 434.3333333337/21/2023
6Product 1247/14/2023
7Product 247/15/2023
8Product 3217/16/2023
9Product 467/17/2023
10Product 1237/18/2023
11Product 2257/19/2023
12Product 3137/20/2023
13Product 437/21/2023
Sheet1
 
Upvote 0
I know you have a solution, but I wanted to show you an altercative with Power Query

I don't know anything about Power Query. Can you tell me how it is enough better for this application than MaxIfs to justify an add-in and code?

Thanks
 
Upvote 0
It is an alternative. However, if you have a continuous list that is ever expanding, then PQ will automatically update when the new data is added and only require you to refresh the worksheet. As you are aware, there are many ways to solve issues in Excel and this is one. It should be noted that it is not an add in for your version and is called Get and Transform Data and found on the Data Tab of the Ribbon. Since this is a public forum database, people look for answers without posting, this is just another means to the end. If anyone is interested in the benefits of PQ, then a link in my signature is a good starting point.
 
Upvote 0
It is an alternative. However, if you have a continuous list that is ever expanding, then PQ will automatically update when the new data is added and only require you to refresh the worksheet. As you are aware, there are many ways to solve issues in Excel and this is one. It should be noted that it is not an add in for your version and is called Get and Transform Data and found on the Data Tab of the Ribbon. Since this is a public forum database, people look for answers without posting, this is just another means to the end. If anyone is interested in the benefits of PQ, then a link in my signature is a good starting point.
Ok, good point.
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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