Share of months above average: reuse one virtual table twice
Build a month table once, take its average, then count the months above it — a consistency score that works for any filter.
You will learn to
- Reuse one virtual table for several calculations
- Compare each row with an aggregate of the same table
- Express a count as a share with DIVIDE
How it works
Some questions compare every row of a table with something calculated **from that same table**: which months beat the average month? Which customers beat the median customer?
The clean way is to build the table once in a variable, then use it several times:
- one variable holds the table, with a computed column (`ADDCOLUMNS`); - a second variable holds a single number calculated from it (`AVERAGEX`); - the `RETURN` filters the table against that number and counts.
Variables are calculated once, where they are defined. So the average is fixed before `FILTER` starts walking the rows, and every row is compared with the same number. Because the month list comes from `VALUES`, a slicer on Year changes which months are in it.
Practice it hands-on with a real data model and a live report that updates as you type.
Customers Above Average =
VAR C = ADDCOLUMNS(VALUES(Customer[Customer]), "Spend", [Total Sales])
VAR AvgSpend = AVERAGEX(C, [Spend])
RETURN COUNTROWS(FILTER(C, [Spend] > AvgSpend))