> For the complete documentation index, see [llms.txt](https://docs.avonnicomponents.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/data-table/manage-column-visibility.md).

# Manage Column Visibility

Show a Data Table column only to the users who need it, such as a Discount column for sales managers, by binding Hidden to a formula.

Sales managers review the discount granted on each deal, while reps working the same opportunities do not need that column. Instead of building two tables, you keep one and bind the **Discount** column's **Hidden** setting to a formula that checks a custom permission.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FsCsZVri2bvg9JZTirHQO%2Fdata-table-tutorial-manage-column-visibility-result.png?alt=media" alt="Two tables of the same five open deals. Sales manager view has the columns Opportunity, Account, Stage, Amount and Discount (12%, 18%, 10%, 20%, 10%); Sales rep view has the same rows without the Discount column"><figcaption><p>The same table for a manager, with Discount, and for a rep, without it.</p></figcaption></figure>

## Before you start

* A Data Table with a **Query** data source on Opportunity, with a **Discount** column. This tutorial uses a custom percent field `Discount__c`. See [Data Table](https://docs.avonnicomponents.com/dynamic-components/components/data-table.md).
* A custom permission that marks who may see the column, for example `View_Discounts`, assigned to managers through a permission set. In Salesforce Setup: **Custom Permissions**, then **New**, then add it to a permission set and assign that set.

{% hint style="warning" %}
**Hidden** only changes what the table displays. It does not protect the data. To keep reps from reading the discount anywhere in Salesforce, use field-level security on the field.
{% endhint %}

## Steps

{% stepper %}
{% step %}

### Create the formula

**Hidden** hides the column when its value is `true`. The formula therefore answers the question "should this user NOT see the column?".

1. Open the **Resources** panel and create a new resource of type **Formula**.
2. Name it `hideDiscount` and set **Data Type** to **Boolean**.
3. Enter:

```
NOT({!$Permission.View_Discounts})
```

A manager with the permission gets `false`, so the column shows. Everyone else gets `true`, so it is hidden.

See [Formula](https://docs.avonnicomponents.com/dynamic-components/component-builder/resources/formula.md) and [Using Variables and Component Data](https://docs.avonnicomponents.com/dynamic-components/core-concepts/using-variables-and-component-data.md) for the global variables you can use.
{% endstep %}

{% step %}

### Bind Hidden to the formula

1. Select the Data Table and, in **Data Mappings**, open **Columns**.
2. Click the **Discount** column.
3. Next to **Hidden**, click the resource selector and choose **Hide Discount** (the builder shows the resource by its label).

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FNUeYnp3UVk4MaZi51dXW%2Fdata-table-tutorial-manage-column-visibility-hidden-binding.png?alt=media" alt="The Discount column settings popover scrolled to Hidden, which shows a resource pill reading Hide Discount instead of a toggle, with Sortable, Hide Default Actions and Wrap Text below" width="320"><figcaption><p>Hidden reads the formula: true hides the column, false shows it.</p></figcaption></figure>
{% endstep %}

{% step %}

### Check the formula before you test (optional)

Add a [Text](https://docs.avonnicomponents.com/dynamic-components/components/text.md) component above the table and set its content to `{!hideDiscount}`. It prints `true` or `false` for the current user. Remove it once the rule works.
{% endstep %}

{% step %}

### Save and test

Save, then open the page as a user with the permission set: the **Discount** column is there. Log in as a rep without it: the table shows the same rows without the column.

Test on the Lightning page itself. The builder preview does not always resolve user and permission values the way the live page does.
{% endstep %}
{% endstepper %}

## Troubleshooting

<details>

<summary>The column is hidden for everyone, or shown for everyone</summary>

Check the formula's direction. **Hidden** expects `true` to hide. A formula that returns `true` for managers hides the column from exactly the people who need it: wrap it in `NOT()`. Then check that the permission set is assigned to the user you test with.

</details>

<details>

<summary>I want the column hidden on some rows only</summary>

Not possible. **Hidden** applies to the whole column. A column also always reads one field, so it cannot switch to another field by record type. Create a formula field on the object that returns the value you want for each row, and use it as the column's source field.

</details>

## Related tutorials

* [Apply Conditional Cell Styling](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/data-table/apply-conditional-cell-styling.md): highlight a value instead of hiding the column.
* [Enable Inline Editing](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/data-table/enable-inline-editing.md): let the managers who see the column edit it.
* [Use Rich Column Types](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/data-table/use-rich-column-types.md): make the columns you keep easier to read.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avonnicomponents.com/dynamic-components/tutorials/components/data-table/manage-column-visibility.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
