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

- JMP User Community
- :
- Discussions
- :
- How do replace the column name with the column number in the formula?

- 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

Sep 12, 2018 7:49 AM
(4950 views)

Just take this table as an example:

The formula for column 2 is the sum of column 4 plus column 5

How to replace "age", "height" and "weight" in the following code with 2, 4 and 5 respectively?Thank you very much!

dt = Current Data Table();

Column( "age" ) << Formula( :height + :weight );

2 ACCEPTED SOLUTIONS

Accepted Solutions

Highlighted

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

@lwx228,

Try the following.

```
dt = Current Data Table();
Column("age") << formula(As Column(column(dt,4)) + As Column(column(dt,5)));
```

Best

Uday

Uday

Highlighted

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

Created:
Sep 12, 2018 8:50 AM
| Last Modified: Sep 12, 2018 8:52 AM
(4930 views)
| Posted in reply to message from lwx228 09-12-2018

The reference to the data table pointer "dt" will fail, unless it is available in the JMP session....so in other words, the formula may not work when you open the data table in a new jmp session....or it may be wrong in the new session, if "dt" points to a different data table. Therefore, the reference needs to be added to the formula, so it is there for you to use:

`Column(dt,6) << formula(dt=current data table(); As Column(dt,4) + As Column(dt,5));`

Note, the formula is also changed. The Column() reference has been removed, since it is redundent.

Also, since the formula know what data table it is pointing to, you can actually reduce the formula to:

`Column(dt,6) << formula(As Column(4) + As Column(5));`

Jim

4 REPLIES 4

Highlighted

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

@lwx228,

Try the following.

```
dt = Current Data Table();
Column("age") << formula(As Column(column(dt,4)) + As Column(column(dt,5)));
```

Best

Uday

Uday

Highlighted
##

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

Re: How do replace the column name with the column number in the formula?

Column(dt,2) << formula(As Column(column(dt,4)) + As Column(column(dt,5)));

Tried it, learned it. Thank you very much!

Tried it, learned it. Thank you very much!

Highlighted

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

Created:
Sep 12, 2018 8:50 AM
| Last Modified: Sep 12, 2018 8:52 AM
(4931 views)
| Posted in reply to message from lwx228 09-12-2018

The reference to the data table pointer "dt" will fail, unless it is available in the JMP session....so in other words, the formula may not work when you open the data table in a new jmp session....or it may be wrong in the new session, if "dt" points to a different data table. Therefore, the reference needs to be added to the formula, so it is there for you to use:

`Column(dt,6) << formula(dt=current data table(); As Column(dt,4) + As Column(dt,5));`

Note, the formula is also changed. The Column() reference has been removed, since it is redundent.

Also, since the formula know what data table it is pointing to, you can actually reduce the formula to:

`Column(dt,6) << formula(As Column(4) + As Column(5));`

Jim

Highlighted
##

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

Re: How do replace the column name with the column number in the formula?

dt = Current Data Table();

Column(dt,2)<< formula(As Column(4) + As Column(5));

thank you!

Column(dt,2)<< formula(As Column(4) + As Column(5));

thank you!

Article Labels

There are no labels assigned to this post.