# Getting errors in simple addition of column values

Solved!
Level 3
###### Getting errors in simple addition of column values

I've built a pivot which presents monthly customer purchases by brand (rows have customer ID, brand, then values for total \$ purchase per month; columns are the months). The columns are of type "decimal".

I'm trying to build a new column which displays the total spend for six months by customer by brand. I'm trying use a simple column_1 + column_2 + ... + column_6 formula in the new column.

I'm getting strange results. For example, a row that features the values: 427.75, 913.0, 495.0, [no value], 150.0, 288.0 is returning the following result: 495.0913.0427.75.

Here's what the formula looks like in the Editor Panel:

Operating system used: MacOS Monterey v12.4

Operating system used: MacOS Monterey v12.4

1 Solution
Dataiker

Hi @wjkelly,

You should be able to achieve the output youโre looking for with the sum() method. I've included an example below for reference.

In some cases, the โ+โ operator can result in concatenation, for instance, if there are missing values in the columns that are being computed. Please see our knowledge base article Safe Sums across Columns in Dataiku DSS Formulas for more details on that.

Please let us know if you have any questions.

Thanks!

Jordan

3 Replies
Dataiker

Hi @wjkelly,

You should be able to achieve the output youโre looking for with the sum() method. I've included an example below for reference.

In some cases, the โ+โ operator can result in concatenation, for instance, if there are missing values in the columns that are being computed. Please see our knowledge base article Safe Sums across Columns in Dataiku DSS Formulas for more details on that.

Please let us know if you have any questions.

Thanks!

Jordan

Level 3
Author

Hi Jordan,

Thanks so much for this response. The sum([column_1,column_2 etc]) solution worked perfectly. And thanks too for the background info to help me understand why the "+" was not an ideal solution here.

Dataiker

Hi @wjkelly,

Great! Glad we could help and thanks for keeping us posted.

Best,

Jordan