diff --git a/scripts/logsheet.js b/scripts/logsheet.js index d1ff713..4e476c3 100644 --- a/scripts/logsheet.js +++ b/scripts/logsheet.js @@ -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; }