Script to filter a table based on the column of another table

Hi,

Here is a situation that we are facing: we would like to use the column of a table to filter a second table (in a dashboard).

I have drafted an example (see picture).

So far, we have been able to draft a script to retrieve filtered data after step 2

Questions:
a) Is it possible to use a script for doing that?
b) If yes, could you indicate to us the method to be used to filter the second table?
c) What would the best: the 2 tables are in the same dashboard or belongs to two different dashboards?

1 Like

Hi @sarah.1

This is definitely do-able.
When the user makes their filter selection, then table 1 changes. In the data changed interaction of table 1, you can have a script. This will run every time that the filter is changed.
The script needs to iterate through column B of table 1 and gather all the values. Then the script can change the value of filter 2 which is connected to table 2.
Both tables are on the same dashboard, although table 1 can be off the canvas.

There are some script examples in the library about how to set the value of a filter via script.

That is how I’ve achieved this before, let me know if you need any more details.

Whether or not this is the best way to achieve your requirements is a different discussion altogether.

2 Likes

Thanks @david.glickman
First part regarding table 1 is vey clear

What is not so clear to me is the following. You mention

Then the script can change the value of filter 2 which is connected to table 2

If we update the value of filter 2 (which is connected to table 2), will it be necessary for the user to click on this filter 2?
We have’nt found how to automatically apply that filter 2 to table 2 (I mean without any user interaction)

Filter 2 (or even parameter 2 - you don’t necessarily need the filter control) will be connected to table 2. Create it as you would setup a filter in the normal way.

You or the user should be able to filter table 2 with this filter, exactly like you can filter table 1 with filter 1. Then move filter 2 off the canvas so the user can’t see it.

When your script runs, it will change filter 2 without the user even knowing that filter 2 exists.
The way to do that is in the examples I linked to in my previous post.

Get the parameter, clear existing values, add the ones you want, and refresh the adapters. Look at the examples and adapt them for your case.

Again, let me know if you need more direction, once you’ve looked at those examples.

2 Likes