Visual Calculations
With visual calculations, you add calculated values to a Power BI visual, such as a remaining budget or a running total. A visual calculation is a DAX expression that works on the data already shown in the visual. You don't need to change the underlying data model.
You can use visual calculations in the dashboards of the Insights app and on the Dashboard tab of the Portfolio app. This article covers the basics and the most common pitfalls. It is not a full DAX reference. For that, see Visual calculations overview (Microsoft Learn).
Before you start
- You need edit rights on the dashboard.
- Visual calculations work on tables, matrices and standard charts. They don't work on slicers, custom visuals, or AI visuals such as Key Influencers and Decomposition Tree.
Before you make bigger changes, take a screenshot of the visual. That makes it easy to compare the result afterwards.
Add a visual calculation
- Open the dashboard in edit mode.
- Right-click the visual and select New visual calculation.
- Choose a template, such as Running sum or Percent of grand total, or select Custom to write your own DAX expression.
- Check the result. The calculation appears as a new column or value in the visual.
Templates
| Template | What it shows |
|---|---|
| Running sum | A cumulative total across rows |
| Moving average | The average over a sliding window |
| Percent of parent | A value as a percentage of its parent group |
| Percent of grand total | A value as a percentage of the grand total |
| Versus previous / next | The difference with the previous or next row |
Rules for your own expressions
- A visual calculation can only use fields that are on the visual. Need a field you don't want to show? Add it to the visual and hide it.
- Field names in square brackets must match the names in the visual exactly. Embedded dashboards have no autocomplete, so check the spelling.
- The calculation works on the values the visual already shows. You usually don't need aggregation functions such as
SUM. - Functions that depend on model relationships, such as
RELATED,RELATEDTABLEandUSERELATIONSHIP, are not available.
Examples
Replace the field names with the names of the fields in your own visual.
| What you want to show | DAX expression |
|---|---|
| Remaining budget | Remaining budget = [Budget] - [Actual Costs] |
| Percentage of budget used | Budget used % = DIVIDE([Actual Costs], [Budget]) |
| Cumulative hours | Running total hours = RUNNINGSUM([Actual Hours]) |
| Share of the grand total | Share of total = DIVIDE([Actual Hours], COLLAPSEALL([Actual Hours], ROWS)) |
| Difference with the previous row | Change vs previous = [Actual Costs] - PREVIOUS([Actual Costs]) |
| Status label | Budget status = IF([Actual Costs] > [Budget], "Over budget", "Within budget") |
Formatting
Number format
- Select the visual calculation.
- In the formatting pane, go to General > Data format.
- Choose a format, or enter a custom format string:
#,##0for whole numbers with a thousands separator.#,##0.00for two decimals.0.0%for a percentage with one decimal.
Formatting on the total row
Formatting such as conditional formatting only applies to values by default. To apply it to the total row as well, open the formatting settings of the field and change Apply to from Values only to Values and totals.
Known limitations
| Limitation | What it means |
|---|---|
| Items without data are hidden | Show items with no data is not available on a visual with a visual calculation. Need all items? Use a separate visual without a calculation. |
| No sorting, filtering or aggregation change | You can't sort or filter a visual by a visual calculation, or change its aggregation. |
| Not in exports | When you export data from the visual, the results of the visual calculation are not included. |
| Not every field is supported | A field that is not compatible blocks the calculation. See Troubleshooting. |
Troubleshooting
The calculation can't be added or gives an error
Most likely, the visual contains a field that does not work with visual calculations. To find it:
- Create a new table visual with only the fields your calculation needs.
- Add the visual calculation and check that it works.
- Add the other fields one by one. Check the result after each field.
- When the calculation stops working, the last field you added is the cause. Remove it or use another field.
Also check the spelling of the field names, and that the expression does not use RELATED, RELATEDTABLE or USERELATIONSHIP.
Items without data have disappeared
This is expected. See Known limitations.
Formatting is missing on the total row
Change Apply to to Values and totals. See Formatting on the total row.
Support
Still stuck? Submit a ticket via the Support Center. See Fortes Customer Support. Include:
- The app and the name of the dashboard.
- The DAX expression you used.
- What you expected and what you see instead.
- A screenshot of the visual, without personal data.