GitHub user dosubot[bot] added a comment to the discussion: X-Axis Sort By does not work without Dimensions
<!-- Answer --> The way X-Axis Sort By works in Superset is intentional and depends on whether you have dimensions (groupby fields) selected. When no dimension is set, you can sort by any column or metric in your dataset. As soon as you add a dimension, the sort options are restricted to a fixed set: category name, total value, min, max, and average value. This is hardcoded in the frontend and not a backend limitation or bug—it's how the control is designed to work in Superset [[source](https://github.com/apache/superset/issues/34352)]. If you want to sort by a metric when no dimensions are present, this should work in bar charts and similar chart types. If it's not working, double-check that your chart type supports this and that your configuration matches the expected setup. For chart types where this isn't supported (like Mixed Chart or some line charts), it's a feature request and not currently available [[source](https://github.com/apache/superset/issues/32412)]. There isn't a built-in workaround to sort by an arbitrary dataset column when a dimension is set. If you need a specific order, consider pre-sorting your data in the dataset or creating a calculated column that encodes your desired order, then use "Category name" sorting [[source](https://github.com/apache/superset/issues/34352)]. The relevant logic for this behavior is in the frontend code, specifically in the `xAxisSortControl` and `sortOperator` functions. Changing this would require a code enhancement [[source](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/customControls.tsx#L59-L151)]. If you have a specific chart type or scenario where sorting by metric is not working as expected without dimensions, let me know which chart type and configuration you're using, and I can help you dig deeper. <!-- 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/9c8b9254-d053-435a-901d-9b8f261c936a?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/9c8b9254-d053-435a-901d-9b8f261c936a?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/9c8b9254-d053-435a-901d-9b8f261c936a?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/9c8b9254-d053-435a-901d-9b8f261c936a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/9c8b9254-d053-435a-901d-9b8f261c936a?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/9c8b9254-d053-435a-901d-9b8f261c936a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/9c8b9254-d053-435a-901d-9b8f261c936a?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=The%20way%20X-Axis%20Sort%20By%20works%20in%20Superset%20is%20intentional%20and%20depends%20on%20whether%20you%20have%20dimensions%20%28groupby%20fields%29%20selected.%20When%20no%20dimension%20is%20set%2C%20you%20can%20sort%20by%20any%20column%20or%20metric%20in%20your%20dataset.%20As%20soon%20as%20you%20add%20a%20dimension%2C%20the%20sort%20options%20are%20restricted%20to%20a%20fixed%20set%3A%20category%20name%2C%20total%20value%2C%20min%2C%20max%2C%20and%20average%20value.%20This%20is%20hardcoded%20in%20the%20frontend%20and%20not%20a%20backend%20limitation%20or%20bug%E2%80%94it%27s%20how%20the%20control%20is%20designed%20to%20work%20in%20Superset%20%5B%5Bsource%5D%28https%3A//github.com/apache/superset/issues/34352%29%5D.%0A%0AIf%20you%20want%20to% 20sort%20by%20a%20metric%20when%20no%20dimensions%20are%20present%2C%20this%20should%20work%20in%20bar%20charts%20and%20similar%20chart%20types.%20If%20it%27s%20not%20working%2C%20double-check%20that%20your%20chart%20type%20supports%20this%20and%20that%20your%20configuration%20matches%20the%20expected%20setup.%20For%20chart%20types%20where%20this%20isn%27t%20supported%20%28like%20Mixed%20Chart%20or%20some%20line%20charts%29%2C%20it%27s%20a%20feature%20request%20and%20not%20currently%20available%20%5B%5Bsource%5D%28https%3A//github.com/apache/superset/issues/32412%29%5D.%0A%0AThere%20isn%27t%20a%20built-in%20workaround%20to%20sort%20by%20an%20arbitrary%20dataset%20column%20when%20a%20dimension%20is%20set.%20If%20you%20need%20a%20specific%20order%2C%20consider%20pre-sorting%20your%20data%20in%20the%20dataset%20or%20creating%20a%20calculated%20column%20that%20encodes%20your%20desired%20order%2C%20then%20use%20%22Category%20name%22%20sorting%20%5B%5Bsource%5D%28https%3A//github.com/apac he/superset/issues/34352%29%5D.%0A%0AThe%20relevant%20logic%20for%20this%20behavior%20is%20in%20the%20frontend%20code%2C%20specifically%20in%20the%20%60xAxisSortControl%60%20and%20%60sortOperator%60%20functions.%20Changing%20this%20would%20require%20a%20code%20enhancement%20%5B%5Bsource%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/customControls.tsx%23L59-L151%29%5D.%0A%0AIf%20you%20have%20a%20specific%20chart%20type%20or%20scenario%20where%20sorting%20by%20metric%20is%20not%20working%20as%20expected%20without%20dimensions%2C%20let%20me%20know%20which%20chart%20type%20and%20configuration%20you%27re%20using%2C%20and%20I%20can%20help%20you%20dig%20deeper.) [](https://go.dosu.dev/discord-bot) [](https://twitter.co m/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/36290) GitHub link: https://github.com/apache/superset/discussions/36290#discussioncomment-15086947 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
