cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
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

Recommended Articles