June7 is on the right track, but a query can accomplish this (two queries actually). Joe4 @ MrExcel gets the Gold star. I also posted in that forum, but didn't see a spot to link.
Here is his solution, which I have also confirmed to work: http://www.mrexcel.com/forum/microso...ml#post3867728
One query ranks the records, and the 2nd query aggregates.
Code:
SELECT Table1.id, Table1.Date, Table1.item, Table1.sales, (SELECT COUNT(Table1A.date)
FROM [Table1] as Table1A
WHERE [Table1A].[date]<=[Table1].[date]
AND [Table1A].[item]=[Table1].[item]) AS [Day]
FROM Table1
ORDER BY Table1.[date];
then
Code:
SELECT Query1.Day, Sum(Query1.sales) AS SumOfsales, Count(Query1.item) AS CountOfitem
FROM Query1
GROUP BY Query1.Day;