Sub topic 12
Hiding fields that a calculation still uses
This chapter assumes you can build a visual in Power BI Desktop and have followed the earlier chapters on creating visual calculations, the visual's row and column layout, and the axis parameter. You should know how a calculation such as RUNNINGSUM([Sales Amount]) reads values from the visual.
Why you would hide a field
A visual calculation can only use fields that are already in the visual. If you want a percent of grand total, Sales Amount must be in the visual, because the calculation reads it from there. That requirement causes a presentation problem. Suppose the report consumer only needs to see the percentage. The raw Sales Amount column is then clutter, and it may even expose numbers you would rather not show.
Hiding solves this. A hidden field stays in the visual's data layout, so calculations can still read it. It is not drawn on the report page. You get a clean visual and keep the inputs the calculation needs.
Hiding is common in these cases:
- You show a ratio, such as percent of parent, and want to omit the underlying amount.
- You build a moving average and want a chart with one line instead of two.
- You split a calculation into steps and want to show only the final result.
- The visual is narrow, and each extra column makes it harder to read.
How to hide and show a field
Hiding is done in the calculation editing experience, not on the report canvas.
- Select the visual and choose New calculation on the ribbon, or select an existing visual calculation to open the edit mode.
- In the visual preview at the top of the editing pane, find the field you want to hide. Each field in the preview has an eye icon.
- Select the eye icon to hide the field. Select it again to show the field.
- Leave the edit mode with Back to report view. The visual now omits the hidden fields.
The preview in the edit mode still shows hidden fields, usually with a visual cue such as a struck-through eye, so that you can keep working with them. This is intentional. You need to see the inputs while you write the formula.
You can also hide a visual calculation in the same way. This is useful when one calculation only exists to feed another.
A worked example
Take a matrix with Year on the rows and Sales Amount as the value. Add this visual calculation:
Percent of grand total = DIVIDE([Sales Amount], COLLAPSEALL([Sales Amount], ROWS))The result shows each year's share of the grand total. The matrix now has three pieces: the Year rows, the Sales Amount values, and the percentage. If the audience only cares about the share, open the edit mode and hide Sales Amount. After you return to the report view, the matrix shows Year and Percent of grand total only.
The calculation still works because it reads Sales Amount from the data layout, not from what is drawn. The numbers in the percentage column do not change when you hide or show the field.
You can also build on a calculation that you hide. Here the first calculation is an intermediate step:
Running sum = RUNNINGSUM([Sales Amount])Running share = DIVIDE([Running sum], COLLAPSEALL([Sales Amount], ROWS))The second calculation refers to Running sum by name, just as it refers to a model field. If you hide Sales Amount and Running sum, the visual shows only Running share. This keeps each formula short and easy to check, which matters when you return to the report months later.
What hiding changes and what it does not
Hiding only affects what is drawn. The table below lists what stays the same.
| Aspect | Effect of hiding a field |
|---|---|
| Value the calculation reads | Unchanged. The calculation sees the same values. |
| Grouping of rows | Unchanged. A hidden field that is on the rows or columns still groups the data. |
| Visibility on the page | The field is not drawn. |
| Field in the field well | The field remains in the visual's field wells. |
| Calculation references | Formulas that name the field still work. |
| Query to the model | The field is still part of the visual's data, so hiding does not make the visual cheaper to compute. |
The last row is a frequent misunderstanding. Hiding is a presentation feature. If a visual is slow, hiding a field will not help. Remove the field, or reconsider whether the logic belongs in a measure.
Hiding grouping fields
You can hide a field that defines rows or columns, not just a value. This needs care.
Suppose a matrix has Year and Quarter on the rows, with Sales Amount as a value. The row hierarchy has two levels, and functions such as COLLAPSE([Sales Amount], ROWS) move between them. If you hide Quarter, the layout still has two levels. A reader sees only the year labels, but the matrix still has a row for each quarter. That produces repeated year labels or confusing row meanings, depending on the visual.
A safer way to get a one-level view is to remove the Quarter field from the visual. Then update any calculation that referred to the removed level. Use hiding for fields whose rows you still want, but whose labels or numbers you do not want to display.
Hiding versus removing
Hiding and removing look similar on the page, but they are different actions.
- Hide a field when a calculation needs it. The calculation keeps working.
- Remove a field when nothing needs it. Remove it from the field well, as you would from any visual.
If you remove a field that a visual calculation uses, the calculation can no longer find it and shows an error. In that case, add the field back and hide it. A calculation that refers to a model field that is not in the visual can fail for the same reason: first add the field to the visual, then hide it if you do not want to see it.
Hidden fields and tooltips, export, and accessibility
Hidden fields are not drawn, but think about where else a visual's data is used.
- Export. When a user exports data from a visual, the export reflects what the visual shows. Do not treat hiding as a security control. If a number is sensitive, keep it out of the visual, and use model-level security for the data.
- Screen readers. The visible fields are what a screen reader works with. If the percentage is the only field shown, add a clear title and name the calculation well, for example
Share of total salesinstead ofCalc1. - Naming. A hidden calculation still needs a clear name, because you will read it in formulas later.
A short checklist
Use this list when you decide how to arrange inputs and outputs in a visual:
- Add every field that the calculation needs to the visual first.
- Write and check the calculation while the inputs are visible, so you can compare the result with the source value.
- Hide the inputs that the audience does not need.
- Name the visible calculation clearly.
- Return to the report view and confirm the layout reads well.
Checking with the inputs visible is the main habit to build. If a percentage looks off, you want to see the Sales Amount values next to it. Hide fields last, after the numbers are correct.
Common errors
- The calculation shows an error after you delete a field. You removed a field that the calculation reads. Add it back and hide it.
- A hidden field still changes the number of rows. The field groups the data. Hiding does not change grouping. Remove the field if you want fewer rows.
- You expect hiding to speed up the visual. It does not. The field is still part of the visual's data.
- You cannot find the hidden field on the page. It does not appear there. Open the edit mode to see and manage it.
Exercise
A matrix has Year on the rows and Sales Amount as a value, plus the visual calculation Percent of grand total = DIVIDE([Sales Amount], COLLAPSEALL([Sales Amount], ROWS)). You want the page to show only Year and the percentage. A colleague suggests removing Sales Amount from the visual. What happens if you do that, and what should you do instead?
Show answer
If you remove Sales Amount, the calculation loses its input and shows an error. Instead, keep Sales Amount in the visual and hide it with the eye icon in the calculation edit mode. The calculation still reads its values, and the report page shows only Year and the percentage.
Exercise
You hide the Quarter field on a matrix that has Year and Quarter on the rows. Does the matrix now have one row per year? Does hiding make the visual query cheaper?
Show answer
No to both. Hiding only changes what is drawn. The row structure still has one row per quarter within each year, and the field is still part of the visual's data, so the query is not cheaper. To get one row per year, remove Quarter from the visual and update any calculation that used that level.