I have a table ‘Questions’ like this:
Item | Importance | Complete |
---|---|---|
Row1 | P1 | True |
Row2 | P2 | True |
Row3 | P3 | False |
I want to have a summary outside the table that shows the sum of Importance based on the numeric values, but only for rows where Complete is True. In this case, the sum would be 3 which is P1 + P2 or 1+2.
To drop the “P” I use the function Right()
and this gives me just the number.
My problem is that I’ve found three formulas that give me the correct answer, but in all three of them Coda gives me an error of “Wrong argument type” with “Sum expects parameter value to be a number, a list of numbers, a formatted number, a list of formatted numbers…”
The formula works perfect, but it tells me that error when I open the formula edit popup.
Here are three variations of the formula:
Sum(Questions.Filter([Complete]).Importance.forEach(Right(CurrentValue,1)))
Here I have Sum() as the top level function with everything inside it.
Questions.Filter([Complete]).Importance.forEach(Right(CurrentValue,1)).Sum()
Here I do the table filtering first and Sum at the end.
Questions.Filter([Complete]).forEach(Right(Importance,1)).Sum()
Here I also have Sum() at the end, but a different position of the forEach loop. It’s more concise because it doesn’t need to reference currentValue.
Conceptually I understand what has to happen. I filter the table to the rows where Complete is true. Then I need to Sum those rows on the Importance column, after converting the values to numbers.
I have three data points:
Questions.filter([Complete])
→ to filter the rows.
Importance.forEach(Right(CurrentValue,1))
→ to convert the values to numbers.
Sum()
→ to add up those numbers.
No matter how I assemble those, Coda says Sum is not getting the right data.
What gives?