<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create a column formula using a column name from a list in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Create-a-column-formula-using-a-column-name-from-a-list/m-p/279876#M54248</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=New Table( "test",
	Add Rows( 4 ),
	New Column( "symbol",
		Character,
		"Nominal",
		Set Values( {"a", "b", "c", "d"} ),
		Set Display Width( 55 )
	),
	New Column( "fold change",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [-3, -0.4, 0.4, 3] ),
		Set Display Width( 68 )
	)
);

l = {"fold change"};

try(New Column( "absolute fold change",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Formula( Abs( column( l[1] )[] ) 
)));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Since your list contains only strings, you need to tell JMP that the string is a column name by using the Column( "" )[ ] function.&lt;/P&gt;&lt;P&gt;The blank square brackets are necessary as well as without them, the formula will reference the&amp;nbsp;&lt;EM&gt;entire column&amp;nbsp;&lt;/EM&gt;instead of only the appropriate row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helped,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lain&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jul 2020 17:52:48 GMT</pubDate>
    <dc:creator>lgober</dc:creator>
    <dc:date>2020-07-17T17:52:48Z</dc:date>
    <item>
      <title>Create a column formula using a column name from a list</title>
      <link>https://community.jmp.com/t5/Discussions/Create-a-column-formula-using-a-column-name-from-a-list/m-p/279862#M54244</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a simple script where I want to create a new column in which a formula calculate the absolute value of another column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;the column is referenced in a list.&lt;/P&gt;&lt;P&gt;I tried a few different ways, but I can't figure out how to evaluate the referenced column so I end up with an empty formula column. Any suggestion would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sebastien&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=New Table( "test",
	Add Rows( 4 ),
	New Column( "symbol",
		Character,
		"Nominal",
		Set Values( {"a", "b", "c", "d"} ),
		Set Display Width( 55 )
	),
	New Column( "fold change",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [-3, -0.4, 0.4, 3] ),
		Set Display Width( 68 )
	)
);

l={"fold change"};

try(New Column( "absolute fold change",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Formula( Abs( l[1] ) 
)));

try(New Column( "absolute fold change 2",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Formula( eval(column(l[1]) ) 
)));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:32:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-a-column-formula-using-a-column-name-from-a-list/m-p/279862#M54244</guid>
      <dc:creator>Sburel</dc:creator>
      <dc:date>2023-06-09T23:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create a column formula using a column name from a list</title>
      <link>https://community.jmp.com/t5/Discussions/Create-a-column-formula-using-a-column-name-from-a-list/m-p/279876#M54248</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=New Table( "test",
	Add Rows( 4 ),
	New Column( "symbol",
		Character,
		"Nominal",
		Set Values( {"a", "b", "c", "d"} ),
		Set Display Width( 55 )
	),
	New Column( "fold change",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Set Values( [-3, -0.4, 0.4, 3] ),
		Set Display Width( 68 )
	)
);

l = {"fold change"};

try(New Column( "absolute fold change",
	Numeric,
	"Continuous",
	Format( "Best", 12 ),
	Formula( Abs( column( l[1] )[] ) 
)));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Since your list contains only strings, you need to tell JMP that the string is a column name by using the Column( "" )[ ] function.&lt;/P&gt;&lt;P&gt;The blank square brackets are necessary as well as without them, the formula will reference the&amp;nbsp;&lt;EM&gt;entire column&amp;nbsp;&lt;/EM&gt;instead of only the appropriate row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helped,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lain&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 17:52:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-a-column-formula-using-a-column-name-from-a-list/m-p/279876#M54248</guid>
      <dc:creator>lgober</dc:creator>
      <dc:date>2020-07-17T17:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create a column formula using a column name from a list</title>
      <link>https://community.jmp.com/t5/Discussions/Create-a-column-formula-using-a-column-name-from-a-list/m-p/279887#M54250</link>
      <description>Thanks a lot, I had tried the option you proposed with one big difference: No empty brackets.&lt;BR /&gt;Best,&lt;BR /&gt;&lt;BR /&gt;Sebastien</description>
      <pubDate>Fri, 17 Jul 2020 18:34:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-a-column-formula-using-a-column-name-from-a-list/m-p/279887#M54250</guid>
      <dc:creator>Sburel</dc:creator>
      <dc:date>2020-07-17T18:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create a column formula using a column name from a list</title>
      <link>https://community.jmp.com/t5/Discussions/Create-a-column-formula-using-a-column-name-from-a-list/m-p/279891#M54251</link>
      <description>No problem. I had this exact same issue yesterday and it took me a while to figure it out.&lt;BR /&gt;&lt;BR /&gt;I actually just learned of another solution to this, too.&lt;BR /&gt;&lt;BR /&gt;The 'As Column()' function will return the value of the current row in the column specified as an argument.&lt;BR /&gt;&lt;BR /&gt;So that formula could equally have been formatted like this:&lt;BR /&gt;&lt;BR /&gt;Formula(&lt;BR /&gt;Abs( As Column( l[1] ) );&lt;BR /&gt;);&lt;BR /&gt;&lt;BR /&gt;Pretty neat!</description>
      <pubDate>Fri, 17 Jul 2020 18:52:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Create-a-column-formula-using-a-column-name-from-a-list/m-p/279891#M54251</guid>
      <dc:creator>lgober</dc:creator>
      <dc:date>2020-07-17T18:52:32Z</dc:date>
    </item>
  </channel>
</rss>

