Collecting total charge value where custom field is X I'm using Charge to collect donations toward individual projects for a charity.

On the frontend, I want to display how much has been raised for an individual project.

To get a list of charges for a project, I'm doing

{% set charges = craft.charge.charges({  
      search : { query : 'projectDonateTo:' ~ entry.id }}
   )%}

{% for charge in charges %}
    {{ charge.amount }}
{% endfor %}


which obviously loops through all charges but I can't fathom how to total these together.

Any ideas?
Can you not do:    

{% set total = 0 %}

{% for charge in charges %}
    {% set total = total + charge.amount %}
{% endfor %}

{{ total|number_format(2, '.', ',') }}


?