Short answer: a visual calculation is a DAX formula stored on one visual, calculated on the numbers the visual already shows. Running sum = RUNNINGSUM([Sales Amount]) adds up the rows of the visual from top to bottom, with no date table logic. They can refer to the visual's structure: the previous row, the parent level, the grand total. Because they work on aggregated data, they are often faster than the equivalent measure. They live on the visual, not in the model, so other visuals cannot reuse them.
A running total by month as a measure needs a date table, DATESYTD or a FILTER over ALLSELECTED, and care with the sort order. As a visual calculation it is one word: RUNNINGSUM. The trade is reuse: the measure works everywhere, the visual calculation only where it was written.
What does a visual calculation look like?
| Month | Sales Amount | Running sum | Versus previous |
|---|---|---|---|
| Jan | 80 | 80 | |
| Feb | 95 | 175 | +15 |
| Mar | 90 | 265 | -5 |
| Apr | 118 | 383 | +28 |
| May | 130 | 513 | +12 |
Running sum = RUNNINGSUM ( [Sales Amount] )
Versus previous = [Sales Amount] - PREVIOUS ( [Sales Amount] )How do you add one?
- Select a visual (a table, matrix or chart with the fields you need).
- Home, New visual calculation, or right-click the visual, New calculation. The visual calculations editor opens with the visual matrix on top.
- Type the formula, or pick a template: Running sum, Moving average, Percent of parent, Percent of grand total, Average of children, Versus previous, Versus next, Versus first, Versus last, and two lookup templates.
- Fields used only to feed a calculation can be hidden on the visual: they stay available to the calculation but do not show.
A visual calculation can refer to columns, measures, or other visual calculations that are in the same visual. A model field must be on the visual before a calculation can use it.
Which functions are made for them?
| Function | Does | Example |
|---|---|---|
| RUNNINGSUM | running total along an axis | RUNNINGSUM([Sales Amount]) |
| MOVINGAVERAGE | average over a window | MOVINGAVERAGE([Sales Amount], 2) |
| PREVIOUS, NEXT | the row before or after | [Sales Amount] - PREVIOUS([Sales Amount]) |
| FIRST, LAST | the first or last row of the axis | DIVIDE([Sales Amount], FIRST([Sales Amount])) |
| COLLAPSE | the value one level up | DIVIDE([Sales Amount], COLLAPSE([Sales Amount], ROWS)) |
| COLLAPSEALL | the grand total of the axis | DIVIDE([Sales Amount], COLLAPSEALL([Sales Amount], ROWS)) |
| EXPAND, EXPANDALL | evaluate one level down, or at the leaf level | EXPAND(AVERAGE([Sales Amount]), ROWS) |
| RANGE | a slice of rows of the axis | SUMX(RANGE(3), [Sales Amount]) |
| LOOKUP, LOOKUPWITHTOTALS | a value at another place in the visual matrix | LOOKUP(SUM([Sales Amount]), [Category], "Bikes") |
What do Axis and Reset do?
Axis says which way to go through the visual matrix: ROWS, COLUMNS, ROWS COLUMNS, COLUMNS ROWS, or including small multiples (ROWS ROWPAGES). The default is the first axis of the visual.
Reset restarts the calculation at a level of the hierarchy. With Year and Month on rows:
Running sum per year = RUNNINGSUM ( [Sales Amount], HIGHESTPARENT )HIGHESTPARENT (equivalent to 1) restarts at each year; LOWESTPARENT (-1) restarts at the immediate parent; NONE (0, the default) never restarts. Reset needs several levels on the axis; with a single field, use PartitionBy instead. Microsoft's advice: prefer Axis and Reset to follow the visual's structure, and use OrderBy and PartitionBy to pin a calculation to specific fields whatever the layout.
Visual calculation or measure?
| Choose | When |
|---|---|
| visual calculation | the result belongs to one visual: running totals, differences between rows, percent of parent in this matrix |
| measure | the number is reused in several visuals, in tooltips, cards, other measures, or by other report authors |
| measure | the logic depends on the model, not on the visual: year over year with a date table, customer counts across tables |
The custom totals of tables and matrices are built on visual calculations: picking "Sum" for a total creates one.
What goes wrong?
- Reusing a visual calculation elsewhere. It exists only on its visual; copy the visual or write a measure.
- Sort order.
PREVIOUSandRUNNINGSUMfollow the visual's order on the axis; a visual sorted by value runs the total in value order. - Fields missing from the visual. A calculation can only use fields placed on the visual; add them and hide them.
- Format. Field formatting does not carry over; format the visual calculation itself.
- Reset on one level. It needs a hierarchy; with one field use PartitionBy.
Where can you check this?
- Microsoft Learn: Visual calculations in Power BI
- Microsoft Learn: RUNNINGSUM function (DAX)
- Microsoft Learn: MOVINGAVERAGE function (DAX)
Where do you start?
Add a Running sum and a Versus previous template to one matrix, then compare the time it took with writing the measures. Visual calculation functions in DAX goes through each function with its parameters.