Hide/show column if row "group" is expanded and highlight duplicate cells

Hello! I had a couple of questions regarding tables.

Question 1:
I have a column that is hidden and the table has a grouped column as well (so I can expand it). When I do expand the row, I want to show this column dynamically. How would I do that with retool?

I don’t see a way to dynamically hide or show a column.

Question 2:
How would I highlight a cell value a different background color when there is a duplicate value in a column? For example: if I have a table like this:

make model vin
test1. test2. 123
test3. test2. 124
test3. test2. 125
test1. test2. 124
test1. test2. 126

I would want to highlight the vin column that has the duplicate "124" numbers in the vin. Nothing else would need to be highlighted.

If you are only able to answer one of the two questions I will take those answers for now! :slight_smile:

Thanks!

Hi @macphreak,

Q1 You can dynamically set the column Hidden field to something like this {{ switch1.value }}. I linked this to a switch to show you how it works.

chrome_iOwyYoINCg

Q2 Something like this should do the trick.

{{ 
  table1.data.filter(row => row.vin === currentSourceRow.vin).length > 1 
    ? "lightyellow"       // highlight color
    : "transparent"       // default (no highlight)
}}
2 Likes

So, for Q1: This "sorta" works but is not working for my table. I am grouping by the first column. And I have expanded table option on. When I expand the "group" is when I need to trigger it. But, it seems like it is only triggering when I exand the row the second time to the table embedded in there (hope this makes sense). But, basically, if you try and group by a particular column and also have expanded rows on, then that is my setup.

For Q2:
Where would I place that code?

Thanks!

For Q1 Can you please send screenshots of your setup with the grouping and when/where it needs to get triggered?

Q2 Place the code in the table >> column >> Appearance >> Background.

chrome_kFAkVdibiv

For Q1:
Here is what it looks like collapsed:

The above is a "Group By" Team Name for the table.

When I expand the "first" grouped by team name above is when I want to show/hide certain columns.

When I expand the first group, it expands to this:

Then, the second expansion actually has a table underneath that one (see below):

So, if I set the table to trigger something on expand row, it only triggers for the second expanded row (not the first expanded group). Hope that makes sense.

If you view this GIF, I basically need to show/hide columns when I click on the first expansion (e.g. clicking the arrow next to the team name "Brad")
CleanShot 2025-04-11 at 11.21.06

For Q2:
I placed it there but this doesn't seem to be working. For example, in your screenshot, it shoud be highlighting cat1 since it is listed there twice. It also seems to be missing blank cells (which would also be seen as a duplicate since they are blanks).

Thank you again for your help!

1 Like

I'm setting up a little testing app. What is the relationship between your first table and your second? I see team members in the first table and presumably clients in the second one with VINs. Is it your team member id in the second table? Even a bigger screenshot of the entire context would help.

Can you also show me an example of duplicate VINs?

The query just brings back the team name, role name, first name and last name of the sales teams and their numbers.

I have that connected to a table. I have the table "Grouped By" the team name.

I also have expandable rows on. When you expand the row, it just shows the leads associated to that sales person. The user ID is associated with the leads assigned to field.

A duplicate vin would a vin number like this:
lead 1: 1234567
and then another VIN in the table that would be
lead 2: 1234567

Most VIN's will be unique. I just need to highlight when the vin has already shown up in the leads table (under a sales person name) or when a vin is blank.

Thanks!

Q1 Which column(s) do you want hidden?
Q2 I think I have a working example.

With this script you highlight any null values as well as duplicates:

{{ 
  currentRow.VIN === null || 
  tableTeamClients.data.filter(r => r.VIN === currentRow.VIN).length > 1
    ? "lightyellow"
    : "transparent"
}}

For Q1: it would be role name, first name and last name (initially hidden and then show them once the group expands).

For Q2: it's still not working for me so I will have to play around with that one a little bit.

For Q1: Ok, I see what you are trying to do. As far as I know, the UI lets users collapse/expand groupings — but there’s no official way to detect the expanded state in code. That state is not exposed via the table’s public properties.

Q2: attached is my working version with the data. Hopefully this will help.

Team admin test (1).json (35.8 KB)
team_members.csv (171 Bytes)
team_clients.csv (217 Bytes)

1 Like

Gotcha. I'll open up a request for that feature then. Thanks for all your help! :+1:t2:

1 Like

FWIW I've tried the grouped function (expandable rows) and find it a little clunky. The columns that aren't hidden (Role name, first name, last name) only make sense to the user once they expand the group. Then, drilling down to find more data like a hidden table can make people think too much.

I would play around with the multi-select component to filter your team names instead of the expandable rows. Then, have your client list with VINs below or beside your main table. This could be filtered in the same manner when selecting a team member.

Apologies if I have overstepped my boundaries to simply answer the question. If you do want to explore alternatives, feel free to reach out anytime. :slight_smile:

1 Like