Getting errors in simple addition of column values

wjkelly
wjkelly Registered Posts: 22 ✭✭✭✭

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

Tagged:

Best Answer

  • JordanB
    JordanB Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 296 Dataiker
    Answer ✓

    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.

    Screen Shot 2022-07-19 at 4.10.15 PM.png

    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

Answers

  • wjkelly
    wjkelly Registered Posts: 22 ✭✭✭✭

    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.

  • JordanB
    JordanB Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 296 Dataiker

    Hi @wjkelly
    ,

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

    Best,

    Jordan

Setup Info
    Tags
      Help me…