4 Replies Latest reply on Oct 23, 2017 2:59 PM by robert b

# Scalar arithmetic

I am trying to create a calculated field where I subtract a constant from all values in one of my columns of data.  I am getting "cannot mix aggregate and non-aggregate values in this function" as an error.  The constant is the sum of one column divided by the sum of another--essentially a weighted average.  I cannot use avg because I need the average to be weighted.  Even if I could, I get the same error with average. This also comes up when I attempt to multiple the value by one of my vectors.

[Shipment Cnt]*([Cost Ship]-[avg_cost]), where shipment Cnt and cost Ship are vectors, and avg_cost=sum(cost ship)/sum(ship cnt)

• ###### 1. Re: Scalar arithmetic

ATTR([Shipment Cnt])*ATTR(([Cost Ship])-[avg_cost])

• ###### 2. Re: Scalar arithmetic

This doesn't seem to work.  The description for ATTR suggests that this will (as a loose, not precise description) compact of ship cnt and cost into a single value (as though it were acting as a functional), to make the entire equation scalar.  I want to go the other way--to keep shipment cnt and cost as vectors and subtract a constant value from all rows of cost.

• ###### 3. Re: Scalar arithmetic

Post an example Robert.

While I can imagine what you are trying to do, an example will vastly assist.

Peter

• ###### 4. Re: Scalar arithmetic

In create calculate field,
[Shipment Cnt]*([Cost Ship]-[avg_cost])
where shipment Cnt and cost Ship are columns of my data, and
avg_cost=sum(cost ship)/sum(ship cnt) is a previous calculation