Calculating the last/latest value in a GROUPBY function?
I've got some sales data, and I've mostly got it doing what I need, but there's one part I'm struggling with.
The (sample) sales data is:
| Date | Time | TotalAmount | TotalItems | AverageValue |
|---|---|---|---|---|
| 01/01/2026 | 10:00:00 | 25 | 2 | 12.50 |
| 01/01/2026 | 11:00:00 | 30 | 3 | 10 |
| ... | ||||
| 01/01/2026 | 23:00:00 | 600 | 50 | 12 |
(the total amount are cumulative, the 11:00:00 numbers include everything from the 10:00:00 sales, plus anything after up to 11:00:00 etc., and average value is just total amount / total items)
I'm using GROUPBY to get an end of day summary:
=GROUPBY(tblSalesAmounts[Date],tblSalesAmounts[[TotalAmount]:[TotalItems]],MAX,0,0,-1)
This works fine as it's the values at the end of the day I'm looking for, but I don't know how to add in the AverageValue - I can't get it via MAX as the average can change throughout the day, and it's last value of the day I'm after.
Any ideas on how to add in a latest/last value, in addition to the max's?
[link] [comments]
Want to read more?
Check out the full article on the original site