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
gallardet
Level III

I need to compare several columns

Hi. 

I have a table with several columns with values that represent total votes obtained by political parties. I need a script that finds the greatest values of these columns and obtains the name of the column, i.e. the political party.

 

Thanks in advance for your help.

 

Manel

2 ACCEPTED SOLUTIONS

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: I need to compare several columns

You can do this with the Formula Editor.

 

Use the Maximum() function to find the max value in the columns and then the Match() function to match it to which column it came from.

 

The attached data table has the example.

 

JMPScreenSnapz023.png

-Jeff

View solution in original post

Jeff_Perkinson
Community Manager Community Manager

Re: I need to compare several columns

The Match() function is under the Conditionals section of the Formula Editor.

 

With the Maximum() funtion built and selected in the Editor, click on Conditionals -> Match. You'll be prompted about adding arguments, select "Do Not Add".

 

Then click on the ^ button in the toolbar to add the four pairs of arguments and then fill them in.

 

ScreenFlow.gif

-Jeff

View solution in original post

4 REPLIES 4
Jeff_Perkinson
Community Manager Community Manager

Re: I need to compare several columns

You can do this with the Formula Editor.

 

Use the Maximum() function to find the max value in the columns and then the Match() function to match it to which column it came from.

 

The attached data table has the example.

 

JMPScreenSnapz023.png

-Jeff
gallardet
Level III

Re: I need to compare several columns

Thanks a lot Jeff,

 

I have a question.

How to do the second part of the formula?

Captura de pantalla 2019-07-08 a les 19.26.20.png

 

 

Jeff_Perkinson
Community Manager Community Manager

Re: I need to compare several columns

The Match() function is under the Conditionals section of the Formula Editor.

 

With the Maximum() funtion built and selected in the Editor, click on Conditionals -> Match. You'll be prompted about adding arguments, select "Do Not Add".

 

Then click on the ^ button in the toolbar to add the four pairs of arguments and then fill them in.

 

ScreenFlow.gif

-Jeff
WebDesignesCrow
Super User

Re: I need to compare several columns

In script form :

dt << New Column( "Maximum",
		Character,
		"Nominal",
		Formula(
			Match(
					Maximum(
						:Party A,
						:Party B,
						:Party C,
						:Party D
					),
				:Party A, "Party A",
				:Party B, "Party B",
				:Party C, "Party C",
				:Party D, "Party D"
			)
		));