I would like to calculate and display the total of each line in the table:
Asked
Active
Viewed 54 times
1 Answers
1
Here you go.
{
"data": {
"values": [
{"departement": "IUT", "group": "BO", "hetd_maquette": 6106},
{"departement": "ECOLE DOCT", "group": "BO", "hetd_maquette": 106},
{"departement": "ENSTRSV", "group": "BO", "hetd_maquette": 3442},
{"departement": "DPT - L.L.S.H.", "group": "BO", "hetd_maquette": 11460},
{"departement": "DPT - D.E.G.", "group": "BO", "hetd_maquette": 9608},
{"departement": "ESPE", "group": "BO", "hetd_maquette": 8220},
{"departement": "DPT - S.T.", "group": "BO", "hetd_maquette": 12332},
{"departement": "SCE - F.C.", "group": "BO", "hetd_maquette": 973},
{"departement": "ECOLE DOCT", "group": "EDS", "hetd_maquette": 106},
{"departement": "DPT - S.T.", "group": "EDS", "hetd_maquette": 12332},
{"departement": "DPT - L.L.S.H.", "group": "EDS", "hetd_maquette": 11460},
{"departement": "DPT - D.E.G.", "group": "EDS", "hetd_maquette": 9616},
{"departement": "SCE - F.C.", "group": "EDS", "hetd_maquette": 973},
{"departement": "IUT", "group": "EDS", "hetd_maquette": 6110},
{"departement": "ESPE", "group": "EDS", "hetd_maquette": 8244},
{"departement": "ENSTRSV", "group": "EDS", "hetd_maquette": 3442},
{"departement": "IUT", "group": "Serv.Ens.", "hetd_maquette": 4824},
{"departement": "ESPE", "group": "Serv.Ens.", "hetd_maquette": 8120},
{
"departement": "DPT - D.E.G.",
"group": "Serv.Ens.",
"hetd_maquette": 9986
},
{
"departement": "DPT - L.L.S.H.",
"group": "Serv.Ens.",
"hetd_maquette": 12524
},
{"departement": "ENSTRSV", "group": "Serv.Ens.", "hetd_maquette": 2961},
{"departement": "SCE - F.C.", "group": "Serv.Ens.", "hetd_maquette": 933},
{
"departement": "DPT - S.T.",
"group": "Serv.Ens.",
"hetd_maquette": 12592
},
{"departement": "ECOLE DOCT", "group": "Serv.Ens.", "hetd_maquette": 85}
]
},
"transform": [
{
"joinaggregate": [{"op": "sum", "field": "hetd_maquette", "as": "Total"}],
"groupby": ["group"]
},
{"calculate": "'Total'", "as": "TotalTitle"}
],
"layer": [
{
"mark": "text",
"encoding": {
"y": {
"field": "group",
"type": "nominal",
"axis": {"title": "", "ticks": false}
},
"x": {
"field": "departement",
"type": "nominal",
"axis": {
"orient": "top",
"labelAngle": 0,
"title": "",
"domain": true,
"ticks": false
},
"scale": {"padding": 15}
},
"text": {"field": "hetd_maquette", "type": "ordinal"}
}
},
{
"mark": "text",
"encoding": {
"y": {
"field": "group",
"type": "nominal",
"axis": {"title": "", "ticks": false}
},
"x": {
"field": "TotalTitle",
"type": "nominal",
"axis": {
"orient": "top",
"labelAngle": 0,
"title": "",
"domain": true,
"ticks": false
},
"scale": {"padding": 15}
},
"text": {"field": "Total", "type": "ordinal", "aggregate": "max"}
}
}
]
}

Davide Bacci
- 16,647
- 3
- 10
- 36