cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMPĀ® Marketplace
Choose Language Hide Translation Bar
galactus3000
Level IV

accessing current column name in formula for that column

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
julian
Community Manager Community Manager

Re: accessing current column name in formula for that column

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:Screen Shot 2019-12-06 at 12.17.50 PM.png

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

 

and here is what it looks like upon a change:

update.gif

 

 

I hope this helps! 

@julian 

View solution in original post

9 REPLIES 9

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?

galactus3000
Level IV

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

 

 

txnelson
Super User

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

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.

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 ) )
galactus3000
Level IV

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"

 

vince_faller
Super User (Alumni)

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
julian
Community Manager Community Manager

Re: accessing current column name in formula for that column

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:Screen Shot 2019-12-06 at 12.17.50 PM.png

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

 

and here is what it looks like upon a change:

update.gif

 

 

I hope this helps! 

@julian 

galactus3000
Level IV

Re: accessing current column name in formula for that column

this is perfect!

thank you!