Hi all, i have a infotable which is returned from Store procedure. The infotable has a column which returns 0 and 1. Is there any way to get the count of the rows which has value 1. Thanks in advance
Solved! Go to Solution.
I think of 2 ways...
var query = {
"filters":{
"type": "EQ",
"fieldName": "<field_name>",
"value": 1
}
};
let params = {
t: <infotable data>/* INFOTABLE */,
query: query /* QUERY */
};
// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);
let params = {
t: <infotable data>/* INFOTABLE */,
columns: <any unique field> /* STRING */,
aggregates: 'COUNT'/* STRING */,
groupByColumns: <0 or 1 field> /* STRING */
};
// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Aggregate(params);
I think of 2 ways...
var query = {
"filters":{
"type": "EQ",
"fieldName": "<field_name>",
"value": 1
}
};
let params = {
t: <infotable data>/* INFOTABLE */,
query: query /* QUERY */
};
// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Query(params);
let params = {
t: <infotable data>/* INFOTABLE */,
columns: <any unique field> /* STRING */,
aggregates: 'COUNT'/* STRING */,
groupByColumns: <0 or 1 field> /* STRING */
};
// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Aggregate(params);
Thanks it works
The approach of Sathishkumar_C is totally fine. But as a short alternative the following is also possible:
const result = infotable.rows.toArray().filter(row => row.valueColumn === 1).length;
infotable --> your infotable variable
valueColumn --> your column name with the value
I will try this too