Visual calculations let you write DAX directly on a visual, so running totals, moving averages and "versus previous" comparisons need no model measure and no filter-context juggling.
Why it matters
- A visual calculation works on the data already shown in the visual, so it is aggregated data, not detail rows. Formulas are shorter, and Microsoft says they often perform better than the equivalent measure.
- It can read the visual's own structure (rows, columns, levels). A normal measure cannot.
How it differs from the other calculation types
| Measure | Calculated column | Visual calculation | |
|---|---|---|---|
| Where it lives | In the model | In the model | On one visual |
| What it sees | Filter context | One row at a time | The visual's aggregated matrix |
| Reusable in other visuals | Yes | Yes | No |
Step by step
- Add every field you need to the visual first. A visual calculation can only use fields that are already in the visual.
- Select the visual, then choose New calculation (Home tab in Power BI Desktop). The edit view shows a visual preview, a formula bar and a matrix of results.
- Type the formula in the formula bar. The matrix updates as you type. Press Ctrl+Space to open the parameter pickers.
- Or start from a template: Running sum, Moving average, Percent of parent, Percent of grand total, Average of children, Versus previous, Versus next, Versus first, Versus last, Look up a value with context, Look up a value with totals. Read the formula the template writes for you.
- Hide helper fields you do not want to show. Hidden fields stay in the matrix, so your formulas can still use them.
- Set the number format in the Data format options (General section of the formatting pane), or use a visual-level format string.
The functions you will use most
| Function | What it does | Shortcut for |
|---|---|---|
RUNNINGSUM | Running sum along an axis | WINDOW |
MOVINGAVERAGE | Moving average along an axis | WINDOW |
PREVIOUS / NEXT | Row before / after on an axis | OFFSET(-1) / OFFSET(1) |
FIRST / LAST | First / last row of an axis | INDEX(1) / INDEX(-1) |
RANGE | A slice of rows on an axis | WINDOW |
COLLAPSE / COLLAPSEALL | Evaluate at a higher level / at the axis total | none |
EXPAND / EXPANDALL | Evaluate at a lower level / at the leaf level | none |
ISATLEVEL | Is a column present at the current level | none |
LOOKUP / LOOKUPWITHTOTALS | Evaluate an expression with the current context (with totals) | none |
Most calculations run once per row of the visual matrix, so you rarely need SUM or other aggregators. USERELATIONSHIP, RELATED and RELATEDTABLE are not available.
Two parameters only visual calculations have
- Axis sets the direction. The default is the visual's first axis, usually
ROWS. Other values:COLUMNS,ROWPAGES(small multiples), and combinations such asROWS COLUMNS. - Reset sets when the calculation starts over. The default is
NONE. UseHIGHESTPARENT(same as 1) to restart at the top level, orLOWESTPARENT(same as -1) to restart under each immediate parent.
Examples
-- Running total of sales, never resets
Running sum = RUNNINGSUM([Sales Amount])
-- Restarts every year when the visual has Year above Month
Running sum by year = RUNNINGSUM([Sales Amount], HIGHESTPARENT)
-- Change versus the previous row on the axis
ProfitVSPrevious = [Profit] - PREVIOUS([Profit])The first two use the page's own function forms, and the third is the page's own example. For percent of parent or percent of grand total, use the templates and read the formula they generate.
Watch-outs
- Unsupported visuals: slicer, R and Python visuals, Key Influencers, Decomposition Tree, Q&A, Smart Narrative, Metrics, Paginated Report, Power Apps, Power Automate and custom visuals.
- Unsupported features: filtering, sorting or changing aggregations on the calculation; self-reference; copy/paste or reuse across visuals; dynamic format strings; personalization; See records drill-through.
- Sharing: you cannot pin to dashboards or use Publish to web. Data exports leave out visual calculation results.
- Live connections: SQL Server Analysis Services needs version 2025 or later.
Best practices
- Use a measure when the same logic is needed in more than one visual, or when you need filtering, sorting or any item on the unsupported list.
- Use
PartitionByinstead ofResetwhen the axis has only one level. - Keep hidden fields to the minimum the calculation needs.
- Name calculations like measures, so the field list stays readable.
Official sources
- Using visual calculations (Microsoft Learn)
- WINDOW function (DAX), which sits underneath
RUNNINGSUM,MOVINGAVERAGEandRANGE