I have an object like:
{
"Account Management": [
{
"rowId": 1288,
"departmentExternalId": "7",
"departmentName": "Account Management",
"measureName": "Total Headcount Expense",
"measureId": 15,
"measureValue": 17282,
},
{
"rowId": 1289,
"departmentExternalId": "7",
"departmentName": "Account Management",
"measureName": "Salary",
"measureId": 5,
"measureValue": 11666,
},
],
"Client Services General (COR)": [
{
"rowId": 1294,
"departmentExternalId": "114",
"departmentName": "Client Services General (COR)",
"measureName": "Total Headcount",
"measureId": 2,
"measureValue": 1,
},
{
"rowId": 1295,
"departmentExternalId": "114",
"departmentName": "Client Services General (COR)",
"measureName": "Total Headcount",
"measureId": 2,
"measureValue": 100,
}
]
}
Each object key represents the department, object obtained after grouping the data got from BE. Now I need to group each object inside department by measureId and count them to obtain something like:
[
{department: "Account Management", measure15: 17282, measure5: 11666},
{department: "Client Services General (COR)", measure2: 101}
]
I tried to group the grouped by department data again by measureId, but I here I have a blocker and don't know how to continue.
If anybody has any idea, please tell me.
Thanks in advance!