cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar

Counting the number of variable columns that have non-zero values

I have a table of formulations.  The amount of each of 60 possible ingredients are listed in columns.  Most of the formulations contain only 5-10 ingredients with the ingredient amount of all other columns being zero.

 

I would like to create a formulation column (without scripting) to count the number of non-zero ingredients.

 

The way I was thinking to do this is to sum conditional statements for each ingredient.  This shows the first 4 ingredients:

kpgallagher_ppg_0-1588779368026.png

 

Is there a quicker/easier way to do this without having to create a string of 60 if statements?

 

Kevin Gallagher
1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Counting the number of variable columns that have non-zero values

You can shorten the code up to

sum( :T400>0,:T402>0,:T404>0,:T405>0)
Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: Counting the number of variable columns that have non-zero values

You can shorten the code up to

sum( :T400>0,:T402>0,:T404>0,:T405>0)
Jim