Sub topic 12
Hiding Fields That a Calculation Still Uses
This chapter assumes you can build a table or matrix in Power BI Desktop and have created a basic visual calculation. It also assumes you know what a measure is and how DIVIDE works.
Why hide a field
A visual calculation can only use fields that are in the visual. Say you want a percent of grand total. You add Sales Amount to the visual, write the calculation, and now the visual shows both Sales Amount and the percentage. If you only want the percentage, the extra column is clutter.
You can hide the field in the visual. A hidden field stays in the visual's data layout, so calculations can still read it. It just doesn't appear in the rendered output.
How to hide a field
- Open the visual and choose Edit calculation to enter the calculation editing experience.
- In the visual matrix at the top, find the field you want to hide.
- Use the eye icon next to the field to hide it. You can also hide it from the field's context menu.
- Select the eye again to show it.
Hiding works for fields from your model and for other visual calculations. Hiding a field here doesn't change the model. It only affects this visual.
Worked example
Start with a matrix that has Calendar Year on rows and Sales Amount as the value. Add this calculation:
Percent of grand total = DIVIDE([Sales Amount], COLLAPSEALL([Sales Amount], ROWS))The matrix now shows two value columns: Sales Amount and Percent of grand total. Hide Sales Amount. The visual shows only the percentage per year, and the calculation still works because Sales Amount is still in the visual's data.
You can also hide an intermediate calculation. Suppose you build a running sum first and then a share of it:
Running sum = RUNNINGSUM([Sales Amount])Running share = DIVIDE([Running sum], COLLAPSEALL([Sales Amount], ROWS))Hide Running sum and Sales Amount, and the visual shows only Running share.
Removing versus hiding
Removing a field from the visual deletes it from the data layout, and any calculation that refers to it breaks. Hiding keeps it. If you want a field out of sight, hide it. Remove it only when no calculation depends on it.
Common errors
- Calculation breaks after cleanup. You removed a field to tidy the visual. Add it back to the visual and hide it.
- Hidden field still appears in a tooltip or export. Hiding affects the rendered visual. Check what your export or tooltip setup includes before sharing a report that contains sensitive values.
- Numbers look wrong after hiding. Hiding doesn't change results. If numbers changed, check whether you also changed the fields on the axes, because that alters the layout the calculation runs against.
- Hiding to protect data. A hidden field is not a security feature. Anyone who can edit the visual can show it again.
Exercise
A matrix shows Calendar Year on rows, Sales Amount, and a calculation Percent of parent = DIVIDE([Sales Amount], COLLAPSE([Sales Amount], ROWS)). You want to show only the percentage. Why should you hide Sales Amount instead of removing it from the visual?
Show answer
The calculation reads Sales Amount from the visual's data layout. Hiding keeps the field in the layout, so the calculation still works and only the percentage is drawn. Removing it would delete the field from the layout and break the calculation.
Exercise
Name one reason hiding a field is not a way to protect sensitive data.
Show answer
Hiding only changes what the visual draws. Anyone who can edit the visual can show the field again, and the values remain in the visual's data.