Sum should provide an error when used without value
When trying to use the sum function I get this error
commit
[#bills name: "Phone", amount: 85]
[#bills name: "Apple Music", amount: 15]
[#bills name: "Internet", amount: 100]
search
[#bills name amount]
total-bills = sum[given: amount]
bind @browser
[#h1 text: "Sum error"]
[#p text: "{{total-bills}}"]
For sum, Eve needs the value to sum over as well:
search
bill = [#bills name amount]
total-bills = sum[value: amount, given: bill]
bind @browser
[#h1 text: "Sum error"]
[#p text: "{{total-bills}}"]
You probably want to use bill as the given here, otherwise if there are multiple bills with the same amount only one of them would get summed. The way to think of given is kind of like "for each unique one of these." So for each unique bill, sum the value.
We definitely should give you better information here and shouldn't be blowing up, so I'll leave this bug up to track that.
Thanks for explaining!
Eve needs the value to sum over as well
It could be helpful to add this explanation to the sum docs as well. That was my first attempt at resolving the problem.
@mndrix Just merged that in actually: https://github.com/witheve/docs/blob/master/handbook/math/sum.md The docs site doesn't update automatically, but I'll do that before I leave the office today.