Forum Discussion
Deneb Split By More Than One Field In X Axis
- 1 year ago
Hi JayWee
Sorry for the late responsre.
Here's a revised version of your Deneb Vega-Lite spec that demonstrates how to concatenate multiple fields into a single X-axis grouping:
***************************************************************
{
"data": {
"name": "dataset"
},
"transform": [
{
"fold": ["Sum of Value_01", "Sum of Value_02"],
"as": ["MT", "value"]
},
{
"calculate": "year(datum.Date) + '-' + month(datum.Date) + ' / ' + datum.Location + ' / ' + datum.Type",
"as": "X_Label"
}
],
"mark": "bar",
"encoding": {
"x": {
"field": "X_Label",
"type": "ordinal",
"axis": {"labelAngle": -45}
},
"y": {
"aggregate": "sum",
"field": "value",
"type": "quantitative"
},
"color": {
"field": "MT",
"type": "nominal"
},
"tooltip": [
{"field": "MT"},
{"field": "value", "type": "quantitative"},
{"field": "X_Label"}
]
}
}
***************************************************************Explanation:
The "calculate" step combines year/month, location, and type into one string (X_Label) for the X-axis.
The x encoding uses this combined field as an ordinal axis.
You can sort or format the string as needed for better visual alignment.
This won’t give you true nested headers like Tableau, but visually it will resemble it with clear separation and stacked bars per grouping.
If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.
Hi JayWee
We haven't heard from you since last response and just wanted to check whether the solution provided has worked for you. If yes, please Accept as Solution to help others benefit in the community.
Thank you.
If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.
Hi Csrikanth,
Apologies for the late reply. Had been sidetracked to work on another high priority project.
With the solution that you've proposed, its showing all under one sentence for each category.
However, the format that i required for my visualisation is breaking down into multiple category, eg. Year, Month, Suburbs, Country.
I had a play around with native visualisation which shows something like this.
After hunting around online and seems like we can only breakdown into 2 category, at least this is the current capability of Deneb as we speak.
Had you came across something similar in the past which allows you to breakdown into multiple catgories like that?
Thanks
Jay