cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
UserID16644
Level V

How to get column sum according to same column values?

Hi all

 

How to calculate the Total Qty if they have the same code? I am currently using Col Sum(:Qty) but it is getting the sum of all column values. I just want the sum of values with the same code & date

 

 

DateCodeQtyTotal Qty
10-23-230049
10-23-230059
10-23-230166
10-24-230333
10-24-230444
10-25-230568
10-25-230528

 

2 REPLIES 2

Re: How to get column sum according to same column values?

You can add the Code column as a grouping variable to achieve this - The required formula is:

Col Sum (Qty , Code) 

I've put this in the attached table to illustrate. 

 

Hope that helps,

Stuart

txnelson
Super User

Re: How to get column sum according to same column values?

Here is the Scripting Index description of the Col Sum()

txnelson_0-1712133647011.png

Note that the function allows for By Variables. Example 4 from the same Scripting Index entry, illustrates the use of the By variables with columns Age and Sex specified as By variables

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column( "Sum for Each Age and Sex Group",
	Formula( Col Sum( :height, :age, :sex ) )
);

With the results

txnelson_1-1712133980667.png

 

 

Jim