Visual calculations
FactSales DimProduct DimDate- Why it matters
- Running totals, moving averages, percent of parent and versus-previous are the most common report calculations. Visual calculations express them in one line on the visual, without filter-context gymnastics.
- Typical production failure
- A model collects dozens of one-off measures ("Running Sales for Chart 3") that nobody else uses and nobody dares delete.
- When to use it
- Calculations that only make sense for one visual's layout: running sums along its axis, percent of the visual's parent, comparisons with the previous row.
- When not to
- Business definitions that other reports need (put those in model measures), or anything you need to filter, sort or export: visual calculations can't be filtered, sorted, reused across visuals or exported.
Assignments
Four visual calculations in ten minutes
- Build a matrix with Dates[MonthName] on rows and [Net Sales] as the value (Beginner model).
- Select the visual → New calculation. Add Running = RUNNINGSUM([Net Sales]).
- Add vs Previous = [Net Sales] - PREVIOUS([Net Sales]) and Moving avg = MOVINGAVERAGE([Net Sales], 2).
- Add Category to rows above MonthName and add Pct of parent = DIVIDE([Net Sales], COLLAPSE([Net Sales], ROWS)).
- Try RUNNINGSUM([Net Sales], HIGHESTPARENT) and explain how it differs from the first running sum.
Measure or visual calculation?
The executive page has six calculations. Decide for each whether it should be a model measure or a visual calculation, considering reuse, filtering, export and performance.
- Net Sales YoY % (used on four pages).
- Running total on one line chart.
- Percent of category total in one matrix.
- Rank of customers used in a slicer.
- Margin % in the KPI dictionary.
- Difference from the first month in one table.
Find the limits
Before recommending visual calculations to the team, test what they can't do.
- Try to filter or sort by a visual calculation.
- Export the visual's data.
- Copy the visual calculation to another visual.
- Use RELATED inside one.
Interview questions
- What is a visual calculation?
- What do the Axis and Reset parameters do?
- Name some functions specific to visual calculations.
- When should you not use a visual calculation?
Assessment
Which expression gives each row's share of its parent in a visual calculation?
- DIVIDE([Sales], CALCULATE([Sales], ALL(Product)))
- DIVIDE([Sales], COLLAPSE([Sales], ROWS))
- RUNNINGSUM([Sales])
- RELATED([Sales])
A visual calculation's results in an Export data file:
- Are included
- Are excluded
- Replace the measures
- Cause the export to fail
Rebuild one running-total measure from the Intermediate DAX topic as a visual calculation, and compare the DAX length and Performance Analyzer timing.
RUNNINGSUM([Net Sales]) vs a CALCULATE with a date filter; visual calculations operate on aggregated data, often faster.