Work around for lack of sum function?

Work around for lack of sum function?

I understand there is no sum function in creator.  I need to create a html view to display an income vs expense with a total of the income items and another total for expense and a grand total that calculates income - expense.  The form has a field for item name and amount and a checkbox for income or expense.  Right now the only way I can make it work is to have each expense amount be a negative number when entered.  This prevents me from being able to make a chart from this data.  If I could sum the expense and income separately I would not need to use the negative numbers and then could make income vs expense charts with the data.  There must be some kind of script to do this.