hayoni
New Contributor

Hi @treesloth 

You can easily do this by using a dashboard parameter to handle the date grouping directly in your SQL query, while keeping the chart's Transform setting as None. Here is the step-by-step setup:

Step 1: Create a dataset for the dropdown options

Create a SQL dataset to build the dropdown list:

  • Dataset name: options_view_mode
SELECT 'Monthly' AS view_mode
UNION ALL
SELECT 'Daily' AS view_mode

dynamic_graph_step1.png

Step 2: Add the parameter and logic to your main dataset

Add a parameter named p_view_mode (Default: "Monthly"), then use a CASE statement to switch the date:

  • Dataset name: dataset_sales_report
SELECT
  *,
  CASE
  WHEN :p_view_mode = 'Daily'
    THEN DATE_TRUNC('DAY', **YOUR_COLUMN_DATE**)
  ELSE DATE_TRUNC('MONTH', **YOUR_COLUMN_DATE**)
  END AS report_date,
  DATE_FORMAT(**YOUR_COLUMN_DATE**, 'yyyy-MM') AS year_month
FROM 
  **YOUR_TABLE**

Note: Be sure to replace YOUR_TABLE and YOUR_COLUMN_DATE with your actual table and column names.

dynamic_graph_step2.png

Step 3: Add the view mode filter to the canvas

Add the view mode filter to the canvas and connect both the dropdown list and the parameter:

  • Filter Type: Single Value
  • Fields: Select "view_mode" from "options_view_mode"
  • Parameters: Select "p_view_mode" from "dataset_sales_report"
  • Default Value: "Monthly"

dynamic_graph_step3.png

Step 4: Add the Month Filter

To let users filter the data down to a specific month. Add another filter widget to the canvas. In the right panel, configure it as follows:

  • Filter Type: Multiple values
  • Fields: Select year_month from dataset_sales_report
  • Title: Month
  • Default Value: Select a default month (e.g., 2026-08)

dynamic_graph_step4.png

Step 5: Set up the Bar Chart

Add your bar chart to the canvas:

  • Dataset: dataset_sales_report
  • X-axis: report_date
  • Y-axis: SUM(sales_amount)
  • Note: Make sure the X-axis Transform is set to None.

dynamic_graph_step5.png

 

Now, you can view a full year of data in Monthly view. When you filter down to just 1 month, simply change the dropdown to Daily to see each day clearly instead of an unhelpful, single huge bar 😆

dynamic_graph_step6.png

 

Hope this helps!