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
- :
- Discussions
- :
- If statement Formula not working

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

Highlighted

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

Feb 6, 2019 12:36 PM
(3004 views)

For the past couple years when I copy and paste the formula below it has not worked consistently. I've tried typing it in the formula box and have at times been succesful but it's not consistent.

I was finally upgraded to JMP 14 last week and an option that is awesome is that I can preview a data sample to see what the formula result will look like. However, I can't figure out why this formula won't work. Below is a screenshot of the formula as well as the preview of the dataset and formula result.

Are there any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions

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

The data looks to be left justified in the preview. Is the data type set to character for the *Behavioral - physical aggression to staff* column? If so, you will need to add double-quotes around the number on the right side of the == operator or change the data type of the column.

Wendy

5 REPLIES 5

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

Re: If statement Formula not working

A possible issue may be that JMP may be having an issue with

`Behaviorial - physical aggression to staff`

Is this a calculation of a column or variable called

Behavioral

from which is subtracted a column or variable called

physical aggression to staff

or

is this a single column or variable called

Behavioral - physical aggression to staff

JMP can get confused over this. If it is one column and not a calculation, you should actually state the formula as

```
If( :Name("Behavioral - physical aggression to staff") == 1,
1,
0
);
```

The JMP formula editor will not display the :Name() function, but by you putting into your formula, it will make sure JMP understands what you are specifying.

Jim

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

Re: If statement Formula not working

Also, if the 1s in the table were calculated, they might not be exactly 1 (which is what you are testing for). The table displays a value that is rounded to *about* 10 digits. Try

`Round(:Name("Behavioral - physical aggression to staff"), 5) == 1`

and see if that works better.

Craige

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

Re: If statement Formula not working

@ernestp for the awesome comment!

Craige

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

The data looks to be left justified in the preview. Is the data type set to character for the *Behavioral - physical aggression to staff* column? If so, you will need to add double-quotes around the number on the right side of the == operator or change the data type of the column.

Wendy

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

Re: If statement Formula not working

Thank you very much! That worked perfectly! This will save me a lot of time.