Sub topic 3
Thinking in the visual's rows and columns
This chapter assumes you can build tables, matrices, and charts in Power BI Desktop. It also assumes you know basic DAX, including measures and aggregations, and that you understand the difference between a measure and a column.
A visual calculation does not run against your data model. It runs against the grid of values that the visual already shows. Once you can picture that grid, most visual calculation behavior becomes predictable.
The visual as a grid
Every visual has a data layout. Take a matrix with Year on rows and Sales Amount as the value. Its layout is a small table:
| Year | Sales Amount |
|---|---|
| 2023 | 120 |
| 2024 | 150 |
| 2025 | 180 |
A visual calculation sees this table and nothing else. It does not see the Date table, the Product table, or any relationships. It sees the rows, the columns, and the cell values the visual produced.
Rows, columns, and cells
Three terms describe the layout:
- Rows are the entries along the vertical axis of the visual. In a matrix these come from the fields in the Rows well.
- Columns are the entries along the horizontal axis. In a matrix these come from the Columns well. Each value field also adds a column.
- Cells are the intersections. Each cell holds one value, such as Sales Amount for 2024.
Functions such as RUNNINGSUM and PREVIOUS move across these rows and columns. They do not filter the model.
Running sum = RUNNINGSUM([Sales Amount])On the grid above, this calculation produces 120, 270, and 450. It adds each row to the rows before it. The model never gets queried again. The calculation reads the cells already in the grid.
Hierarchies in the layout
When you place several fields in the Rows well, the rows form a hierarchy. For example, Year and Quarter give you a parent level (Year) and a child level (Quarter).
| Level | Row | Sales Amount |
|---|---|---|
| Year | 2024 | 150 |
| Quarter | Q1 | 30 |
| Quarter | Q2 | 40 |
| Quarter | Q3 | 35 |
| Quarter | Q4 | 45 |
Each quarter has a parent, which is its year. Each year has the grand total above it. Later chapters use this structure for percent of parent and percent of grand total.
flowchart TDThe diagram below shows the same idea as a tree.
Why the layout matters
The grid has three consequences you will meet often:
- The calculation depends on the visual. If you add or remove a field in the visual, the grid changes and the result changes with it.
- Order follows the axis. Functions that move across rows use the order in which the visual displays them. Sorting the visual changes what "previous" means.
- Only visible data exists. If a value is not in the grid, a visual calculation cannot reach it. You would need to add the field to the visual first. A later chapter covers hiding such fields so they do not clutter the display.
Reading a calculation against the grid
Look at this calculation:
Change vs previous = [Sales Amount] - PREVIOUS([Sales Amount])For 2024, PREVIOUS returns the 2023 cell, so the result is 150 − 120 = 30. For 2023, there is no previous row, so PREVIOUS returns blank and the result is 120. Reading each formula as "which cell does this point to?" is the most reliable habit for this feature.
Exercise
A matrix shows Year on rows with Sales Amount values of 120, 150, and 180 for 2023, 2024, and 2025. What does RUNNINGSUM([Sales Amount]) show for 2025, and why can it not use data from the Product table?
Show answer
It shows 450 (120 + 150 + 180). A visual calculation only reads the cells in the visual's own grid, so Product data is available only if a Product field is added to the visual.