# Nodered-ui-tabulator Calculations For Grouped Data

**URL:** https://discourse.nodered.org/t/nodered-ui-tabulator-calculations-for-grouped-data/95855
**Category:** Dashboard
**Created:** [7 March 2025 16:44 UTC](https://discourse.nodered.org/t/nodered-ui-tabulator-calculations-for-grouped-data/95855 "2025-03-07T16:44:11Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![SergioRT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sergiort/32/19289_2.png) [@SergioRT](https://discourse.nodered.org/u/SergioRT)
#### Post date: [7 March 2025 16:44 UTC](https://discourse.nodered.org/t/nodered-ui-tabulator-calculations-for-grouped-data/95855/1 "2025-03-07T16:44:11Z")

</div>

As you can see below, I have two levels of grouping data

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/3352bc98376529f43dd73ab8239901f73659bf57.png)

The calculation is right for the second level but not for the first level.

Any idea

Thanks in advance

---

<div class="post-metadata">

### Author: ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)
#### Post date: [8 March 2025 09:54 UTC](https://discourse.nodered.org/t/nodered-ui-tabulator-calculations-for-grouped-data/95855/2 "2025-03-08T09:54:04Z")

</div>

Please send a reduced flow highlighting the issue, so I can investigate

---

<div class="post-metadata">

### Author: ![SergioRT](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sergiort/32/19289_2.png) [@SergioRT](https://discourse.nodered.org/u/SergioRT)
#### Post date: [8 March 2025 13:55 UTC](https://discourse.nodered.org/t/nodered-ui-tabulator-calculations-for-grouped-data/95855/3 "2025-03-08T13:55:58Z")

</div>

Thanks for your anwer !  
So can you confirm that sum should appear in top-level group too ?

Properties from ui\_tabulator

```auto
{
	"height": 580,
	"layout": "fitColumns",
	"selectable": true,
	"groupBy": ["espace","categorie"],
	"groupStartOpen": true,
    "addRowPos": "top",
	"columnCalcs":"group",
	"groupClosedShowCalcs":true,
	"columns": [
		{
			"field": "id",
			"editable":false,
			"visible": false
		},
		{
			"title": "Espace",
			"field": "espace",
			"hozAlign": "left",
			"editable": false,
			"visible": false
		},
		{
			"title": "Catégorie",
			"field": "categorie",
			"width": "0%",
			"hozAlign": "left",
			"editor": "input",
			"editable": false,
			"visible": false
		},
		{
			"title": "Index",
			"field": "cctp",
			"formatter": "input",
			"width": "5%",
			"hozAlign": "left",
			"editable": true,
			"editor": "input"
		},
		{
			"title": "Titre",
			"field": "titre",
			"formatter": "input",
			"width": "20%",
			"hozAlign": "left",
			"editable": false,
			"editor": "input"
		},
		{
			"title": "Description",
			"field": "description",
			"formatter": "textarea",
			"width": "20%",
			"hozAlign": "left",
			"editable": true,
			"editor": "textarea"
		},
		{
			"title": "PU",
			"field": "prixUnitaire",
			"width": "10%",
			"hozAlign": "center",
			"editor":"input",
			"editable": true
		},
		{
			"title": "Q",
			"field": "quantite",
			"editable": true,
			"width": "5%",
			"hozAlign": "center",
			"editor": "input"
		},
		{
			"title": "PT",
			"field": "prixTotal",
			"width": "10%",
			"editable": false,
			"hozAlign": "center",
			"topCalc":"@F:somme"
		},
		{
			"field": "modele",
			"visible": false
		},
		{
			"title": "Zone",
			"field": "zone",
			"formatter": "input",
			"width": "10%",
			"hozAlign": "left",
			"editable": false,
			"editor": "input"
		},
		{
			"title": "Niveau",
			"field": "niveau",
			"formatter": "input",
			"width": "5%",
			"hozAlign": "left",
			"editable": false,
			"editor": "input"
		},
		{
			"title": "Modèle",
			"field": "designation",
			"formatter": "input",
			"width": "15%",
			"hozAlign": "left",
			"editable": false,
			"editor": "input"
		}
	]
}

```

and fonction somme

```auto
function somme(values, params) {
    var calc = 0;

    values.forEach(function(element) {
        element = element.slice(0,-2);
        element = element.replace(/\u00A0/g, '');
        element = element.replace(/,/g, '.');
        calc += parseFloat(element);
    });
    
    calc = calc.toLocaleString("fr-FR", { style: "currency", currency: "EUR" });
    return calc;
}

```

---

<div class="post-metadata">

### Author: ![omrid](https://avatars.discourse-cdn.com/v4/letter/o/77aa72/32.png) [@omrid](https://discourse.nodered.org/u/omrid)
#### Post date: [10 March 2025 10:15 UTC](https://discourse.nodered.org/t/nodered-ui-tabulator-calculations-for-grouped-data/95855/4 "2025-03-10T10:15:54Z")

</div>

This is all about Tabulator functionality.

As much as I can see (you are welcome to dig further into the tabulator documentation), Tabulator can show the column calculation in group level, table level or both, but not in the top group

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/c/fce2dba1ee8db7c6e2c95821cfe9452595d6dda7.png)

You may consider adding a function which shows the top group sum in its title.

A few more things:

1. Why not use numeric values for prixTotal, and use the built-in calculator "sum"?
2. In your table definition, you have several columns with formatters of type "input", which is invalid (it's only valid for the "editor" property), and throw errors. Remove them. (in general, it is a good idea during development to have the browser's console log open, to see error messages).

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [9 April 2025 10:16 UTC](https://discourse.nodered.org/t/nodered-ui-tabulator-calculations-for-grouped-data/95855/5 "2025-04-09T10:16:27Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
