Discussions
Calculated Count field
about 8 years ago by Lubos
How do I create calculated "Count" field?
// input
var people = [
{Name: 'Jane', Age: 20, Location: 'Smithtown'},
{Name: 'Ken', Age: 57, Location: 'Islip'},
{Name: 'Tom', Age: 10, Location: 'Islip'}
];
// here is what I've got so far
var result = new jinqJs()
.from(people)
.groupBy('Location')
.select([{ field: 'Location', text: 'label' }, { value: count function here maybe???, text: 'y' }]);
//result I am after is:
var result = [{"label": "Smithtown","y": 1}, {"label": "Islip","y": 2}];