Choose Language Hide Translation Bar
Highlighted

## 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
Highlighted

## 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
Highlighted

## 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.

2 REPLIES 2
Highlighted

## 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
Highlighted

## 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.

Article Labels

There are no labels assigned to this post.