Sub topic 14
Limitations and choosing between visual calculations and measures
This chapter assumes you can build a visual calculation with functions such as RUNNINGSUM and COLLAPSE. It also assumes you know how a measure evaluates under filter context. Here you learn where visual calculations stop working and how to choose between them and measures.
What a visual calculation cannot do
A visual calculation is stored in one visual and runs against that visual's data layout. Most of its limits follow from that design.
- It cannot be reused. Another visual cannot call it. If three visuals need the same logic, you copy the expression three times.
- It cannot be used outside the visual. Slicers, filters, other visuals, and the model do not see it. It does not appear in the Data pane.
- It sees only the fields in the visual. It can read fields on the visual, including hidden ones, but it cannot reach a model column that is not there. If you remove a field from the visual, any calculation that depends on it breaks.
- It depends on layout. Functions like PREVIOUS and RUNNINGSUM follow the order of rows and columns, so sorting, adding a field, or changing the axis can change the result.
- It does not change filter context. Measures can use CALCULATE and filter functions to change what data is aggregated. A visual calculation only reshapes values already in the visual.
Support also depends on the visual type, the data source, and the Power BI version. Some sources and publishing options are not supported. Check Microsoft's current documentation before you commit a design to a specific connection type or embedding scenario.
Layout dependence in practice
A calculation like this one works only because of the visual's row order:
Change vs previous = [Sales Amount] - PREVIOUS([Sales Amount])If a user re-sorts the table by Sales Amount, "previous" now means the next-larger row, not the previous month. The formula is still valid, but the meaning has changed. A measure that uses a date table and an explicit period, such as DATEADD, does not have this problem.
A measure for the same job
This measure gives each row's share of the grand total, and any visual can use it:
Percent of grand total (measure) =
DIVIDE(
[Sales Amount],
CALCULATE([Sales Amount], REMOVEFILTERS())
)It is longer than COLLAPSEALL([Sales Amount], ROWS), but it lives in the model and keeps its meaning whatever visual it appears in.
Choosing between them
| Situation | Better choice |
|---|---|
| Running total or moving average for one chart | Visual calculation |
| Percent of parent in one matrix | Visual calculation |
| KPI used on many pages | Measure |
| Logic that needs a date table or time intelligence across the model | Measure |
| Value used in a slicer, filter, or another calculation | Measure |
| Quick one-off comparison for exploration | Visual calculation |
Common mistakes
- Treating a visual calculation as a shortcut for a shared KPI, then finding the logic copied in many places with small differences.
- Changing a visual's fields or sort order and not rechecking the calculation results.
- Removing a field that a calculation uses, or that you hid for it, and getting an error.
Exercise
A report has a running total of sales by month in one line chart. The same running total is now requested on two more pages, and the finance team wants to filter on it in a slicer. Should you keep it as a visual calculation? Why or why not?
Show answer
No. A visual calculation lives in a single visual, so other visuals cannot reuse it and a slicer or filter cannot use it. Write the running total as a measure in the model so every visual and filter can use it.