đŸ› ī¸
Developer docs
Start BuildingGuides
  • ✨Getting Started
  • đŸŽ›ī¸Self Hosted Config
  • âœī¸SSO Login
    • Saml Identity Provider (Idp)
    • Oidc Identity Provider (Idp)
  • đŸŽžī¸Framework Specific Guide
    • âš›ī¸Reactjs
    • âš›ī¸Nextjs
    • âš›ī¸Vuejs
    • âš›ī¸Angular
    • âš›ī¸Svelte
    • âš›ī¸Solid
    • âš›ī¸Vanilla JS
  • â„šī¸Token
  • đŸ›ī¸Multi-Tenant Access Control
  • Embed using iFrame (Not Recommended approach)
  • 🔑License Key Validation for Self-Hosted App
  • Test
  • 👩‍đŸ’ģHelpers
    • âœŗī¸Token Body
    • ✅Options
      • Custom Fiscal Year filter setup in DataBrain
    • đŸˆ‚ī¸Server Event
    • Embed Functions
    • Override Language
    • âœˆī¸Embedding Architecture
    • âœˆī¸LLM Architecture
    • ✨LLM Connectors
      • Open AI
      • Claude AI
      • Azure Open AI
      • Llama
      • Mixtral
    • 🆔Dashboard ID
    • 🆔Metric ID
    • 🆔API Token
    • 🆔End User Metric Creation
    • Embedding APIs
      • Sync Datasource
  • Metric App Filter
  • Dashboard App Filter
  • Chat Mode
    • Step 1: Create Datamart and Workspace
    • Step 2: Create Data App and Embed ID
  • ✨Solutions Alchemy
    • Dashboards for Client Groups
    • Dashboard for Multiple Clients
    • Embedding: Role based Dashboard Filtering
    • Localized Currency Symbols
    • Manage Metrics
Powered by GitBook
On this page
  • Step 1:
  • Step 2:

Dashboard App Filter

PreviousMetric App FilterNextStep 1: Create Datamart and Workspace

Last updated 3 months ago

Dashboard App Filter: Instruction Manual

Using the App Filter in Dashboard

Step 1:

Create a Dashboard Filter

  • In your dashboard, create a new filter.

  • In the "Apply On" section, enable the App Filter option.

Step 2:

Passing Filter Values

Method 1: Passing from Component

  • Use the parameter "global-filter-options" to pass values directly from a component to the dashboard filter.

  • Configuration changes based on the Filter Type and the Data Type.

  1. Single-Select Filter:

  • For string-based filters, pass just the value:

global-filter-options={
  JSON.stringify({
    "Filter name for a string datatype": {
      defaultOption: 'James Smith'
    },
    "Filter name for a number datatype": {
      defaultOption: {min: 100, max: 900}, // number range
    },
    "Filter name for a date datatype": {
      defaultOption: {startDate: '2024-01-01', endDate: '2024-12-31'}, // date range
    },
  })
}
  1. Multi-Select Filter:

  • For string-based filters, pass an array of values:

    global-filter-options={
      JSON.stringify({
        "Filter name for a string datatype": {
          options: [
            { value: 'James Smith', label: 'James' },
            { value: 'Olivia Johnson', label: 'Olivia' },
            { value: 'Emma Brown', label: 'Emma' },
          ], // in case you want the drop down.
          defaultOption: ['James Smith', 'Emma Brown'], // selected values
        },
        "Filter name for a number datatype": {
          defaultOption: {min: 100, max: 900}, // number range
        },
        "Filter name for a date datatype": {
          defaultOption: {startDate: '2024-01-01', endDate: '2024-12-31'}, // date range
        },
      })
    }
    

Refer the below "Options" document for further queries.

Method 2: Passing from Guest Token

  • You can link a guest token here to pass the filter values dynamically.

Refer the below document to generate a guest token.

{
  "clientId": "id",
  "workspaceName": "workspacename",
  "params": {
    "dashboardAppFilters": [
      {
        "dashboardId": "dashboard-id",
        "values": {
          // single string
          "name": "Eric",
          // multi select
          "country": ["USA", "CANADA"] || "USA", // based on filter variant(select or multi select)
          // date-picker
          "timePeriod": { "startDate": "2024-01-01", "endDate": "2024-3-23" },
          // range
          "price": { "min": 1000, "max": 5000 }
        }
        "isShowOnUrl": true, // true/false
      }
    ]
  }
}

Make sure the options and values match the data type of the filter for successful integration.

Method 3: Handling Large Selections with SQL Integration

Filters with a large number of options (e.g., over 500), manually passing all values becomes inefficient. With SQL integration, you can dynamically fetch options from your database, simplifying the process.

The SQL query specified under the "sql" key dynamically fetches the latest values from the specified database table.

{
  "clientId": "id",
  "workspaceName": "workspacename",
  "params": {
    "dashboardAppFilters": [
      {
        "dashboardId": "dashboard-id",
        "values": {
          // single string
          "name": "Eric",
          "country": {
            "sql": "SELECT \"name\" FROM \"public\".\"countries\" WHERE isEnabled=true",
            "columnName": "name"
          }
          // date-picker
          "timePeriod": { "startDate": "2024-01-01", "endDate": "2024-3-23" },
          // range
          "price": { "min": 1000, "max": 5000 }
        }
        "isShowOnUrl": true, // true/false
      }
    ]
  }
}

Key Benefits:

  1. Dynamic Updates: The SQL query retrieves only the latest relevant options from your database.

    • Example: SELECT "name" FROM "public"."countries" WHERE isEnabled=true fetches active country names.

  2. Efficiency: Eliminates the need to manually manage large datasets in the configuration.

  3. Flexibility: The columnName specifies the field in the query result to use as filter values.

  4. Scalability: Handles thousands of options seamlessly, reducing payload size and improving performance.

This approach is ideal for keeping filters updated with minimal effort, ensuring they remain efficient and user-friendly.

✅Options
â„šī¸Token