Subscribe Bookmark RSS Feed

SumIf equivalent in Column Formula

m4mazzotti

Community Member

Joined:

Apr 17, 2015

I will explain what I am trying to achieve with an example

IDValueSum
1513
1613
299
311
1213

I have a column with a bunch of IDs, they can repeat. Then a have a second column with different values for those IDs.

On the 3rd column, I am trying to have a formula to sum all the Values from all the rows that have the same ID as the current row.

For Row 1 we have, ID = 1, so 5+6+2= 13

Any ideas on how to do that?

1 REPLY
michael_jmp

Staff

Joined:

Jun 23, 2011

Using the ColSum() function with a second argument to specify a By variable should work. The script below recreates your table, using a formula for the third column:

New Table( "Data",

     Add Rows( 5 ),

     New Column( "ID",

     Numeric,

          "Continuous",

     Set Values( [1, 1, 2, 3, 1] )

  ),

     New Column( "Value",

     Numeric,

          "Continuous",

     Set Values( [5, 6, 9, 1, 2] )

   ),

     New Column( "SumIf",

     Numeric,

          "Continuous",

         Formula( Col Sum( :Value, :ID ) )

     )

)

Hope that helps,

Michael

Michael Crotty
Sr Statistical Writer
JMP Development