cancel
Showing results for 
Search instead for 
Did you mean: 
Warehousing & Analytics
Engage in discussions on data warehousing, analytics, and BI solutions within the Databricks Community. Share insights, tips, and best practices for leveraging data for informed decision-making.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Create Parameter-Based Dynamic Charts in Databricks AI/BI Dashboard

Akshay_Petkar
Contributor III

I am currently building a dashboard in Databricks AI/BI and would like to implement a parameter-based chart selection feature. The goal is to allow users to choose a metric from a dropdown (such as Sales, Cost, or Profit), and based on that selection, the chart should dynamically update to display the corresponding values.

Example Use Case:
If a user selects:

  • Sales, the chart should display Sales

  • Cost, the chart should display Cost

  • Profit, the chart should display Profit

I want to create this interactivity through a dropdown or button component that controls which metric is shown in the chart. However, I am unable to find a way to implement this kind of parameter-driven logic in the Databricks dashboard.

Has anyone successfully implemented something similar? Any guidance, tips, or workarounds would be greatly appreciated.

Akshay Petkar
1 REPLY 1

BigRoux
Databricks Employee
Databricks Employee

Here is something to consider:

To implement a parameter-based chart selection feature in a Databricks AI/BI dashboard, follow these steps:
  1. Utilize Dashboard Parameters to Drive Dynamic Updates:
    • Databricks dashboards support the use of parameters to dynamically insert values into dataset queries at runtime. Parameters can be connected to visualization widgets, enabling data queries to adapt based on selections made via dropdown menus or other input widgets.
  2. Define Query-Based Parameters:
    • Create a dataset with the parameterized SQL query. For example, to support a dynamic dropdown: sql SELECT Metric, Value FROM YourTable WHERE Metric = :selected_metric
    • Replace :selected_metric with the parameter name, allowing dashboard viewers to choose the metric from a dropdown menu.
  3. Configure the Parameter List:
    • For a dynamic dropdown, create a dataset query that lists all metrics: sql SELECT DISTINCT Metric FROM YourTable New metrics added to the dataset will automatically appear in the dropdown.
  4. Connect Parameters to a Filter Widget:
    • Add a dropdown filter widget to the dashboard canvas. This widget allows viewers to pick a value like "Sales," "Cost," or "Profit" from the dropdown. The filter widget should be connected to the visualization query parameter through the configuration panel.
  5. Set Default Values and Allow Interactivity:
    • Set default values for parameters to ensure the dashboard displays meaningful data upon initial load or if no selection is made.
    • Allow multiple selections if required by enabling the Allow multiple selections option in the parameter's configuration.
  6. Test the Configuration:
    • Run the parameterized SQL query in the Data tab to preview the results. Verify the behavior when different parameter values are applied.
By linking the dropdown widget to parameters and embedding those parameters in your SQL query, you can achieve the desired dynamic chart selection functionality efficiently in Databricks dashboards.

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now