Question

Create dynamic time frame for dimension group

  • 24 January 2022
  • 0 replies
  • 114 views

I want to use parameter to allow users to change timeframes on the dashboard so they can choose between rolling up their data at the date, week, or month level.

dimension_group: s_date {
    label: "dy_Date"
    type: time
    convert_tz: no
    sql: ${TABLE}.s_date ;;
  }
 

parameter: timeframe_picker{
  label: "Time Frame"
  type: string
  allowed_value: { value: "Daily" }
  allowed_value: { value: "Weekly" }
  allowed_value: { value: "Monthly" }
  allowed_value: { value: "Quarterly" }
  allowed_value: { value: "Yearly" }
  default_value: "Daily"
}

dimension: s_timeframe {
label: "Dy Date Time Frame"
type: string
sql:
CASE
WHEN {% parameter timeframe_picker %} = 'Daily' THEN CAST(${s_date_date} as string)
WHEN {% parameter timeframe_picker %} = 'Weekly' THEN CAST(${s_date_week} as string)
WHEN{% parameter timeframe_picker %} = 'Monthly' THEN CAST(${s_date_month} as string)
WHEN{% parameter timeframe_picker %} = 'Quarterly' THEN CAST(${s_date_quarter} as string)
WHEN{% parameter timeframe_picker %} = 'Yearly' THEN CAST(${s_date_year} as string)
END ;;
}

 

I am trying to add Dy Date Time Frame to filter in the dashboard, but it only shows the data by date instead of selecting by date, weekly, monthly, quarterly and yearly. How to solve it? thanks! 


This topic has been closed for comments