# How To: Conditionally Show/Hide Table Columns

Use conditional column logic when a table should adapt to the current record.

### Problem

You want certain columns to appear only when specific conditions are met.

### Solution

**Hide Column for Closed Opportunities:**

```
<column showcolumn="{{!Opportunity.StageName}} != 'Closed Won'">Expected_Close_Date__c</column>
```

**Show Column for Specific Stages:**

```
<column showcolumn="({{!Opportunity.StageName}} == 'Prospecting' || {{!Opportunity.StageName}} == 'Qualification')">Next_Step__c</column>
```

**Complete Example with Headers:**

```
<table>
  <thead>
    <tr>
      <th>Product</th>
      <th>Price</th>
      <!--RENDER='{{!Opportunity.Type}}' == 'New Business'-->
      <th>Discount</th>
      <!--ENDRENDER-->
    </tr>
  </thead>
  <tbody>
<!--{{!
<lineitems>
<listname>opportunitylineitems</listname>
<column>PricebookEntry.Product2.name</column>
<column prefix="$" format-number="#,###.##">unitprice</column>
<column showcolumn="{{!Opportunity.Type}} == 'New Business'" postfix="%">Discount</column>
</lineitems>
}}-->
  </tbody>
</table>
```

### Operators You Can Use

| Operator | Meaning    | Example                                      |
| -------- | ---------- | -------------------------------------------- |
| `==`     | Equals     | `{{!Opportunity.StageName}} == 'Closed Won'` |
| `!=`     | Not equals | `{{!Opportunity.Type}} != 'Renewal'`         |
| \`       |            | \`                                           |
| `&&`     | AND        | `(condition1 && condition2)`                 |

### Tips

* Apply the same condition to the header with `RENDER` tags.
* Wrap OR and AND expressions in parentheses.
* The column hides when the condition returns `false`.
* Test with different record states before rollout.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.sdocs.com/sdocs/advanced-template-logic/template-attributes/template-attributes-how-to-guides/how-to-conditionally-show-hide-table-columns.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
