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
- :
- Re: accessing current column name in formula for that column

- 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

Dec 6, 2019 6:02 AM
(741 views)

how do I reference the column name of column containing formula in the formula?

for instance, if column name is "* 3 bears*" i want to fill that column (or any column) with a formula like this:

**Num(Word(1,current column name()))**

such that the column will be filled with the number 3

and upon renaming the column to "* 16 dogs*" it would fill the column with the number 16

the intended application for this feature is less mundane than this ... the extracted number will be incorporated into a non-simple column formula

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

Hi @galactus3000,

I agree with others that there is probably a more efficient way of solving whatever problem you have than using a self-referencing formula to extract the numeric part of the column name. That said, I thought it was an interesting challenge! There isn't (so far as I know) a way to self-reference the originating column via jsl (the way we can use Row(), for example), but we can take advantage of the fact that jmp will automatically update references to a column in scripts and formulas when you change a column name. This means we can reference the column itself in an absolute way, and when you change the name and rerun formulas (important) jmp will update all the rows.

Specifically, here's the formula I would use:

`Num( Word( 1, :Name( "16 dogs" ) << get name ) )`

and here is what it looks like upon a change:

I hope this helps!

9 REPLIES 9

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

Re: accessing current column name in formula for that column

I don't think a column formula will do what you want. You are changing the contents upon which the formula depends and the data type. You have to create a new data column if you want to use a column formula.

You could use a short script to iterate over all the columns or a list of selected columns and then change the attribute and value. The original data column would be transformed or changed.

It is not clear what you want to do overall, but can your non-simple column formula extract the desired number from the dependent column name?

Learn it once, use it forever!

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

Re: accessing current column name in formula for that column

the data type of the column in question is numeric and set as such with no changes intended

i want to populate the column with a value which is computed from a value contained in the column name itself, more specifically, the numerical value of the 1st Word in the column name

it could be the case that JMP cannot identify to a formula the column in which the formula exists

if that is the case, this question is a non-starter

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

Re: accessing current column name in formula for that column

A JSL script(not a formula) should be able to do what you want.

Jim

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

Re: accessing current column name in formula for that column

I know what you want to do. I am asking if you really need to do it this way. Instead of populating the entire column with the same value to be used in another formula, the final formula could extract the value, too. Eliminate the need for the intermediate value.

Learn it once, use it forever!

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

Re: accessing current column name in formula for that column

If each of the columns to be changed is already set to numeric data, then this column formula should work:

`Num( Word( 1, name << Get Name ) )`

Learn it once, use it forever!

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

Re: accessing current column name in formula for that column

Mark,

just tried entering this/your formula on a column named "43 birds"

`Num( Word( 1, name << Get Name ) )`

and instead of filling column with 43, just received this error

*Name Unresolved: name 1 times At rows: 2 Operation: name, name/*###*/*

in an error box entitled "Column 43 birds Formula Interrupted"

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

Re: accessing current column name in formula for that column

Assuming you're not changing the position of the Column, you could use it's position.

`Num( Word( 1, Column(1) << Get Name ) )`

But I'd agree that you probably don't need to have this intermediary step.

Vince Faller - Predictum

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

Hi @galactus3000,

I agree with others that there is probably a more efficient way of solving whatever problem you have than using a self-referencing formula to extract the numeric part of the column name. That said, I thought it was an interesting challenge! There isn't (so far as I know) a way to self-reference the originating column via jsl (the way we can use Row(), for example), but we can take advantage of the fact that jmp will automatically update references to a column in scripts and formulas when you change a column name. This means we can reference the column itself in an absolute way, and when you change the name and rerun formulas (important) jmp will update all the rows.

Specifically, here's the formula I would use:

`Num( Word( 1, :Name( "16 dogs" ) << get name ) )`

and here is what it looks like upon a change:

I hope this helps!

Highlighted
##

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

Re: accessing current column name in formula for that column

this is perfect!

thank you!