Skip to Content

Solution Patterns

Filter dashboards by role

Show each role in a customer company only the rows that role may see.

Your backend maps the user’s role to allowed values. The guest token then locks those values. Viewers cannot change them.

Before you start

  • Your backend knows each user’s role.
  • You know which column holds the restricted value, for example region.

Choose the tool

You wantUse
Every query on a table limited, on every dashboard and metricparams.tableAppFilters
One dashboard filter locked to a valueparams.dashboardAppFilters
One metric filter locked to a valueparams.appFilters

tableAppFilters is the strongest. A query on that table that Databrain cannot filter is refused, never run unfiltered.

Steps

  1. In your backend, map the role to values, for example a regional manager to ["East"].
  2. Add the values to the guest token:
{
  "clientId": "acme-corp",
  "dataAppName": "Customer Analytics",
  "params": {
    "userIdentifier": "jane@acme.example",
    "tableAppFilters": [
      { "tableName": "public.orders", "columnName": "region", "values": ["East"] }
    ]
  }
}
  1. When a user’s role changes, create a new token. A token keeps its values until it expires.

The user now sees only East rows from public.orders, inside their own client.

Rules for tableAppFilters

  • tableName is schema.table, as the datamart shows it.
  • columnName is a plain column name.
  • values holds 1 to 1000 strings or numbers.
  • At most 50 entries, one per table column.

To lock a single filter instead, see Dashboard App Filter.

If something goes wrong

  • 400 INVALID_TABLE_APP_FILTER: “Table ‘<name>’ is not in the datamart.” Use the name exactly as the datamart shows it.
  • 400 INVALID_TABLE_APP_FILTER: “Column ‘<col>’ is not in table ‘<name>’ of the datamart.” Check the column name.
  • 400 INVALID_REQUEST_BODY: “tableAppFilters has two entries for the same table column; merge their values into one entry”. Merge them.

Related: Security.