This how what array of object looks like. attributes__assigned_region is a array of multiple values or it can be a single value too
[{
"attributes__assigned_region": [
"w",
],
"count": 1
},
{
"attributes__assigned_region": [
"x"
],
"count": 1
},
{
"attributes__assigned_region": [
"y"
],
"count": 1
},
{
"attributes__assigned_region": [
"z"
],
"count": 2
},
{
"attributes__assigned_region": [
"x",
"z",
],
"count": 2
},
{
"attributes__assigned_region": [
"y",
"z",
],
"count": 2
},
{
"attributes__assigned_region": [
"x",
"y",
],
"count": 4
},
{
"attributes__assigned_region": [
"w",
"y",
],
"count": 3
},
{
"attributes__assigned_region": [
"x",
"y",
"z"
],
"count": 5
},
{
"attributes__assigned_region": [
"x",
"y",
"w"
],
"count": 5
},
]
I want to get array of object like
[{
"attributes__assigned_region": [
"w",
],
"count": 9 // the total from all count where w is avalaible (1 + 3 + 5 )
},
{
"attributes__assigned_region": [
"x"
],
"count": 17 // the total from all count where y is available (1 + 2 + 4 + 5 + 5)
},
{
"attributes__assigned_region": [
"y"
],
"count": 20 // the total from all count where y is available (1 + 2 + 4 + 3 + 5 + 5)
},
{
"attributes__assigned_region": [
"z"
],
"count": 11 // the total from all count where y is available (2 + 2 + 2 + 5)
}]
attributes__assigned_region needs to be a unique set and count will get added from each attributes__assigned_region.count