Applying Filter to multiple Tables

Hi

I have a couple of tables, both using exactly the same data, but different level of detail (one is aggregated per store, while the other aggregates overall).
I was wondering if there is any way to apply the same filter (meaning, using the table filter shortcut in retool) to both tables - for instance, if I'm going to filter by stores that sold at least X amount of products, that filter will apply in both levels.

Thanks

I think you would have to write a js query to filter both tables. Without seeing the data/screenshots it's difficult to say what you should do.

1 Like

Hey @GiladSha,

A straightforward option would be to just filter at the query level.

For a table filter I would do what @ScottR suggested. Something like:

const planFilter = searchSubscriptionPlanFilter;
const subscriptionFilter = searchSubscriptionStatusFilter;

var filters = [];

if (planFilter.value != null) {
  filters.push({ columnName: "pricing_plan_name", operator: "contains", filterValue: planFilter.selectedLabel});
}

if (subscriptionFilter != null) {
  filters.push({ columnName: "subscription_status", operator: "contains", filterValue: subscriptionFilter.value});
}

table1.setFilters(filters);
table1.selectPage(0);

table2.setFilters(filters);
table2.selectPage(0);

You would also need a handler for removing the filters on all tables when your inputs clear.

Hope that helps.

2 Likes