Calc versus Value Functions

When creating calculations in cPlans, you might be confused by the two Spectre functions: calc() and value(). What is the difference between these two functions?

The value() function gets a value from a column, while the calc() function substitutes the given calculation as it comes out of the cPlan.

For example:

calc "Avg Cases Value" `average(value("Cases"))`

determines the average of the values of the column Cases. On the other hand,

calc "Avg Cases Calc" `average(calc("Cases"))`

gets expanded to:

calc "Avg Cases Calc" `average(sum(value("Cases")))`

which gives the average of the single value, which is the total of Cases. Because the total of Cases is the sum of the value of the Cases column, the average, in this case, is the total.

See also: