Average inventory over a period with AVERAGEX
Average the month-end stock across the months in view, the right way to show average inventory for a quarter or a year.
You will learn to
- Average a closing balance over months with AVERAGEX
- Explain why AVERAGE of the snapshot column is per product, not per month
- Make an average that adapts to any number of months
How it works
The closing stock of a year only describes one day. **Average inventory** describes the whole period: the average of the month-end balances. It feeds other KPIs, such as stock turnover, because it isn't distorted by one unusual month end.
Iterate the months with `AVERAGEX(VALUES('Date'[YearMonth]), …)`. `VALUES` returns the months visible in the row (3 in a quarter, 12 in a year), and for each one the expression is evaluated with that month as the filter, thanks to context transition. Average a **closing balance measure** there, so each month contributes one snapshot.
A plain `AVERAGE(Inventory[Units On Hand])` is a different number: it averages every product row, so you get the average stock of one product, not of the store.
Practice it hands-on with a real data model and a live report that updates as you type.
Avg Monthly Customers = AVERAGEX(VALUES('Date'[YearMonth]), [Customers])