dosubot[bot] commented on issue #37485: URL: https://github.com/apache/superset/issues/37485#issuecomment-3804216721
<!-- Greeting --> Hi @madankgit! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team. <!-- Answer --> This happens because setting the X-axis time format to %a only changes how each date is displayed—it doesn't change how the data is grouped or aggregated. With time grain set to "Day," each date remains a unique data point, so you get repeated weekday labels for each week in your data. Superset doesn't currently have a built-in option to group or aggregate by weekday (e.g., all Mondays together) in the chart UI; grouping by weekday requires explicit aggregation logic in your dataset or query, not just display formatting [[source](https://github.com/apache/superset/issues/31927)]. To group by weekday, you can add a calculated column to your dataset (or use custom SQL in Explore) that extracts the weekday name or number from your date column, then use this new column as your group by field in the chart. For example, in SQL: `EXTRACT(DOW FROM date_value)` or `TO_CHAR(date_value, 'Day')` depending on your database. This will let you aggregate all Mondays, Tuesdays, etc., together and display a single ordered set of weekday labels [[source](https://github.com/apache/superset/issues/31927)]. There are ongoing discussions about making dynamic group by easier in the future, but as of now, this workaround is the recommended approach [[source](https://github.com/apache/superset/issues/35158)]. For best results, use both the weekday number (for sorting) and the name (for labeling) to ensure correct order on the X-axis. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/b1a25610-33c8-42bc-8459-0186db90958f?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/b1a25610-33c8-42bc-8459-0186db90958f?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/b1a25610-33c8-42bc-8459-0186db90958f?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/b1a25610-33c8-42bc-8459-0186db90958f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/b1a25610-33c8-42bc-8459-0186db90958f?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/b1a25610-33c8-42bc-8459-0186db90958f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/b1a25610-33c8-42bc-8459-0186db90958f?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=This%20happens%20because%20setting%20the%20X-axis%20time%20format%20to%20%25a%20only%20changes%20how%20each%20date%20is%20displayed%E2%80%94it%20doesn%27t%20change%20how%20the%20data%20is%20grouped%20or%20aggregated.%20With%20time%20grain%20set%20to%20%22Day%2C%22%20each%20date%20remains%20a%20unique%20data%20point%2C%20so%20you%20get%20repeated%20weekday%20labels%20for%20each%20week%20in%20your%20data.%20Superset%20doesn%27t%20currently%20have%20a%20built-in%20option%20to%20group%20or%20aggregate%20by%20weekday%20%28e.g.%2C%20all%20Mondays%20together%29%20in%20the%20chart%20UI%3B%20grouping%20by%20weekday%20requires%20explicit%20aggregation%20logic%20in%20your%20dataset%20or%20query%2C%20not%20just%20display%20formatting%20%5B%5Bsource%5D%28https% 3A//github.com/apache/superset/issues/31927%29%5D.%0A%0ATo%20group%20by%20weekday%2C%20you%20can%20add%20a%20calculated%20column%20to%20your%20dataset%20%28or%20use%20custom%20SQL%20in%20Explore%29%20that%20extracts%20the%20weekday%20name%20or%20number%20from%20your%20date%20column%2C%20then%20use%20this%20new%20column%20as%20your%20group%20by%20field%20in%20the%20chart.%20For%20example%2C%20in%20SQL%3A%20%60EXTRACT%28DOW%20FROM%20date_value%29%60%20or%20%60TO_CHAR%28date_value%2C%20%27Day%27%29%60%20depending%20on%20your%20database.%20This%20will%20let%20you%20aggregate%20all%20Mondays%2C%20Tuesdays%2C%20etc.%2C%20together%20and%20display%20a%20single%20ordered%20set%20of%20weekday%20labels%20%5B%5Bsource%5D%28https%3A//github.com/apache/superset/issues/31927%29%5D.%0A%0AThere%20are%20ongoing%20discussions%20about%20making%20dynamic%20group%20by%20easier%20in%20the%20future%2C%20but%20as%20of%20now%2C%20this%20workaround%20is%20the%20recommended%20approach%20%5B%5Bsource%5D%28https %3A//github.com/apache/superset/issues/35158%29%5D.%20For%20best%20results%2C%20use%20both%20the%20weekday%20number%20%28for%20sorting%29%20and%20the%20name%20%28for%20labeling%29%20to%20ensure%20correct%20order%20on%20the%20X-axis.) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/issues/37485) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
