GitHub user dosubot[bot] added a comment to the discussion: Implement the 
ability to concatenate X-axis values

<!-- Answer -->
Superset already has built-in support for this! When you add multiple columns 
to the X-axis (groupby), Superset automatically concatenates their values with 
commas, so your labels would appear as **"USA, NV, Las Vegas"**.

If you need a different separator (like spaces), the best approach is to create 
a **calculated column** at the dataset level using SQL:

```sql
CONCAT(COUNTRY, ' ', STATE, ' ', CITY)
-- or depending on your database:
COUNTRY || ' ' || STATE || ' ' || CITY
```

Then use this single calculated column as your X-axis dimension instead of the 
three separate columns.

To add a calculated column:
1. Go to your dataset in Superset
2. Navigate to the "Calculated Columns" tab
3. Add a new column with the SQL expression above
4. Use that column in your chart's X-axis

The comma separator in the built-in behavior is [hardcoded in the 
`extractGroupbyLabel()` 
function](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts#L403-L425),
 so the SQL approach is recommended for custom formatting.


<!-- 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/3cf9a910-50ce-4c21-b399-86ef244f8cf0?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/3cf9a910-50ce-4c21-b399-86ef244f8cf0?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/3cf9a910-50ce-4c21-b399-86ef244f8cf0?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/3cf9a910-50ce-4c21-b399-86ef244f8cf0?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/3cf9a910-50ce-4c21-b399-86ef244f8cf0?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/3cf9a910-50ce-4c21-b399-86ef244f8cf0?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/3cf9a910-50ce-4c21-b399-86ef244f8cf0?feedback_type=other)</sup>

[![Chat with 
Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)&nbsp;[![Open
 in 
Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=Superset%20already%20has%20built-in%20support%20for%20this%21%20When%20you%20add%20multiple%20columns%20to%20the%20X-axis%20%28groupby%29%2C%20Superset%20automatically%20concatenates%20their%20values%20with%20commas%2C%20so%20your%20labels%20would%20appear%20as%20%2A%2A%22USA%2C%20NV%2C%20Las%20Vegas%22%2A%2A.%0A%0AIf%20you%20need%20a%20different%20separator%20%28like%20spaces%29%2C%20the%20best%20approach%20is%20to%20create%20a%20%2A%2Acalculated%20column%2A%2A%20at%20the%20dataset%20level%20using%20SQL%3A%0A%0A%60%60%60sql%0ACONCAT%28COUNTRY%2C%20%27%20%27%2C%20STATE%2C%20%27%20%27%2C%20CITY%29%0A--%20or%20depending%20on%20your%20database%3A%0ACOUNTRY%20%7C%7C%20%27%20%27%20%7C%7C%20STATE%20%7C%7C%20%27%20%27%20%7C%7C%20CITY%0A%60%60%60%0A%0AThen%20
 
use%20this%20single%20calculated%20column%20as%20your%20X-axis%20dimension%20instead%20of%20the%20three%20separate%20columns.%0A%0ATo%20add%20a%20calculated%20column%3A%0A1.%20Go%20to%20your%20dataset%20in%20Superset%0A2.%20Navigate%20to%20the%20%22Calculated%20Columns%22%20tab%0A3.%20Add%20a%20new%20column%20with%20the%20SQL%20expression%20above%0A4.%20Use%20that%20column%20in%20your%20chart%27s%20X-axis%0A%0AThe%20comma%20separator%20in%20the%20built-in%20behavior%20is%20%5Bhardcoded%20in%20the%20%60extractGroupbyLabel%28%29%60%20function%5D%28https%3A//github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/plugins/plugin-chart-echarts/src/utils/series.ts%23L403-L425%29%2C%20so%20the%20SQL%20approach%20is%20recommended%20for%20custom%20formatting.)&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share
 on X](https://img.shields.io/badge/X-share-black)](h
 
ttps://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/38097)

GitHub link: 
https://github.com/apache/superset/discussions/38097#discussioncomment-15861065

----
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]

Reply via email to