Create dashboard variable of Interval type:
Auto option can be customized with Step count config. Use that env variable in the groupping definition, e.g. for InfluxDB GROUP BY time($agg).
You will have option to define auto aggregation or to select custom aggregation. Keep in mind that will allow users to select dangerous combination, which may kill your datasource, e.g. 1 sec time aggregation for one year time period.
