Finally figured this one out. I replaced the line:
math "mean(percentage)"
with:
if {rowCount | eq 0} then=0 else={math "mean(percentage)"}
If the datatable is not empty, then it returns the average of the "percentage" column, otherwise it returns an "average" value of 0. Now I no longer get the error triangle at runtime of the canvas.