Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- How can I write a good condition if else if in JMP

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Sep 3, 2018 2:47 AM
(5016 views)

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Craige

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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

Craige

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

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.