cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-71032%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EJMP%E4%B8%AD%E5%A6%82%E4%BD%95%E5%AF%AB%E5%87%BA%E5%A5%BD%E7%9A%84%E6%A2%9D%E4%BB%B6if%20else%20if%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71032%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%82%A8%E5%A5%BD%EF%BC%8C%E6%88%91%E6%9C%89%E5%B9%BE%E5%88%97%E6%95%B8%E6%93%9A%EF%BC%8C%E6%88%91%E6%83%B3%E6%B7%BB%E5%8A%A0%E5%8F%A6%E4%B8%80%E5%80%8B%E5%88%97%EF%BC%8C%E5%AE%83%E5%B0%87%E5%BE%97%E5%88%B0%E5%A6%82%E4%B8%8B%E5%85%AC%E5%BC%8F%EF%BC%9A%3C%2FP%3E%3CP%3EABC%3C%2FP%3E%3CP%3E2%205%3C%2FP%3E%3CP%3E3%204%3C%2FP%3E%3CP%3E5%205%3C%2FP%3E%3CP%3E4%207%3C%2FP%3E%3CP%3EC%20%E5%88%97%E5%B0%87%E5%BE%97%E5%88%B0%20if%20else%20%E5%85%AC%E5%BC%8F%EF%BC%8C%E4%BE%8B%E5%A6%82%EF%BC%9A%20If(A%26amp%3BB%3D%3D4%20then%20C%20%3D%3DGood)%20else%20if(A%26amp%3BB%3D%3D3%20then%20C%20%3D%3Dbad)%20else%20if(A%26amp%3BB%3D%3D1%20then%20C%20%3D%3DGood)%3C%2FP%3E%3CP%3E%E6%88%91%E6%80%8E%E6%A8%A3%E6%89%8D%E8%83%BD%E6%8A%8A%E9%80%99%E5%80%8B%E5%AF%AB%E6%88%90%E5%85%AC%E5%BC%8F%E5%91%A2%EF%BC%9F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71212%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E5%A6%82%E4%BD%95%E5%9C%A8JMP%E4%B8%AD%E7%B7%A8%E5%AF%AB%E4%B8%80%E5%80%8B%E5%A5%BD%E7%9A%84%E6%A2%9D%E4%BB%B6if%20else%20if%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71212%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%AD%A4%E4%BB%A3%E7%A2%BC%E5%B0%87%E5%9F%B7%E8%A1%8C%E6%82%A8%E6%89%80%E6%8F%8F%E8%BF%B0%E7%9A%84%E6%93%8D%E4%BD%9C%EF%BC%9A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENew%20Table(%20%22Untitled%22%2C%20Add%20Rows(%206%20)%2C%0A%20New%20Column(%20%22A%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%20%22Best%22%2C%2012%20)%2C%0A%20%20Set%20Values(%20%5B2%2C%203%2C%205%2C%204%2C%204%2C%201%5D%20)%20)%2C%0A%20New%20Column(%20%22B%22%2C%20Numeric%2C%20%22Continuous%22%2C%20Format(%20%22Best%22%2C%2012%20)%2C%0A%20%20Set%20Values(%20%5B5%2C%204%2C%205%2C%207%2C%204%2C%201%5D%20)%20)%2C%0A%20New%20Column(%20%22C%22%2C%20Character%2C%20%22Nominal%22%2C%20Formula(%0A%20%20%20If(%20%3AA%20%3D%3D%204%20%26amp%3B%20%3AB%20%3D%3D%204%2C%20%22Good%22%2C%0A%20%20%20%20%3AA%20%3D%3D%203%20%26amp%3B%20%3AB%20%3D%3D%203%2C%20%22Bad%22%2C%0A%20%20%20%20%3AA%20%3D%3D%201%20%26amp%3B%20%3AB%20%3D%3D%201%2C%20%22Good%22%0A%20%20%20)%0A%20%20)%0A%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%E5%85%8B%E9%9B%B7%E6%A0%BC%E7%9A%84%E9%8F%88%E6%8E%A5%E9%9D%9E%E5%B8%B8%E5%A5%BD%EF%BC%8C%E7%89%B9%E5%88%A5%E6%98%AF%E5%9B%A0%E7%82%BA%E5%AE%83%E8%A8%8E%E8%AB%96%E4%BA%86%E7%A9%BA%E5%80%BC%E6%9C%83%E7%99%BC%E7%94%9F%E4%BB%80%E9%BA%BC%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-71039%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9B%9E%E5%A4%8D%EF%BC%9A%E5%A6%82%E4%BD%95%E5%9C%A8JMP%E4%B8%AD%E7%B7%A8%E5%AF%AB%E4%B8%80%E5%80%8B%E5%A5%BD%E7%9A%84%E6%A2%9D%E4%BB%B6if%20else%20if%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-71039%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2FUncharted%2FIf-Secrets%2Fm-p%2F39558%23U39558%22%20target%3D%22_blank%22%3E%E5%A6%82%E6%9E%9C%E7%A7%98%E5%AF%86%3C%2FA%3E%E5%B0%8D%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20If()%20%E5%87%BD%E6%95%B8%E6%9C%89%E5%BE%88%E5%A5%BD%E7%9A%84%E6%8F%8F%E8%BF%B0%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
axcelenator1
Level III

How can I write a good condition if else if in JMP

Hello I have several columns with data and I want to add another col which will get a formula like this:

A B C

2 5

3 4

5 5

4 7

C column will get an if else formula for example: If(A&B==4 then C ==Good) else if(A&B==3 then C ==bad) else if(A&B==1 then C ==Good)

How can I write this in a formula ?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Craige_Hales
Super User

Re: How can I write a good condition if else if in JMP

If Secrets has a good description of how to use the If() function.

Craige

View solution in original post

pmroz
Super User

Re: How can I write a good condition if else if in JMP

This code will do what you described:

New Table( "Untitled", Add Rows( 6 ),
	New Column( "A", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [2, 3, 5, 4, 4, 1] ) ),
	New Column( "B", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [5, 4, 5, 7, 4, 1] ) ),
	New Column( "C", Character, "Nominal", Formula(
			If( :A == 4 & :B == 4, "Good",
				:A == 3 & :B == 3, "Bad",
				:A == 1 & :B == 1, "Good"
			)
		)
	)
);

Craig's link is excellent, especially because it discusses what happens with null values. 

View solution in original post

2 REPLIES 2
Craige_Hales
Super User

Re: How can I write a good condition if else if in JMP

If Secrets has a good description of how to use the If() function.

Craige
pmroz
Super User

Re: How can I write a good condition if else if in JMP

This code will do what you described:

New Table( "Untitled", Add Rows( 6 ),
	New Column( "A", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [2, 3, 5, 4, 4, 1] ) ),
	New Column( "B", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [5, 4, 5, 7, 4, 1] ) ),
	New Column( "C", Character, "Nominal", Formula(
			If( :A == 4 & :B == 4, "Good",
				:A == 3 & :B == 3, "Bad",
				:A == 1 & :B == 1, "Good"
			)
		)
	)
);

Craig's link is excellent, especially because it discusses what happens with null values. 

Recommended Articles