Fix: aggBy.total and aggBy.avg
- Fixed: aggBy.total and aggBy.avg to return null when no record has a valid number value
This commit is contained in:
parent
1341f25dd6
commit
40560c5824
@ -294,15 +294,19 @@
|
||||
aggBy.total = function (sheet_id, sheet, attribute) {
|
||||
if (!(sheet_id in floGlobals.appObjects.logSheet.sheetList))
|
||||
throw ("Sheet not found")
|
||||
let result = 0;
|
||||
let result = 0, count = 0;
|
||||
let attrubuteIndex = floGlobals.appObjects.logSheet.sheetList[sheet_id].attributes.indexOf(attribute)
|
||||
sheet.forEach(l => {
|
||||
if (!_isNaN(l.log[attrubuteIndex])) {
|
||||
let value = parseFloat(l.log[attrubuteIndex])
|
||||
result += value;
|
||||
count++;
|
||||
}
|
||||
});
|
||||
|
||||
if (count == 0)
|
||||
result = null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -318,7 +322,10 @@
|
||||
count++;
|
||||
}
|
||||
})
|
||||
result = result / count;
|
||||
if (count == 0)
|
||||
result = null;
|
||||
else
|
||||
result = result / count;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user