<?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 Return the Name of a referenced column in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Return-the-Name-of-a-referenced-column/m-p/935242#M109100</link>
    <description>&lt;P&gt;I'm writing a helper function that renames the a column group if it contains a particular column name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Cities.jmp" );

/*//Use if already existing
dt = Data Table ("Cities");
*/

dt &amp;lt;&amp;lt; group columns( "xy", {:X, :y} );
dt &amp;lt;&amp;lt; group columns( "pollutants", :Ozone :: :Lead );

match_col = "X";
new_name = "coordinates";

groups_list = dt &amp;lt;&amp;lt; get column groups names;
show(groups_list);

For Each({grp, ig}, groups_list,
	cols = dt &amp;lt;&amp;lt; get column group( grp );
	show(cols);
	For Each ({column, ic}, cols,
		show(column);
		colname = column &amp;lt;&amp;lt; Get Name;
		If(colname == match_col,
			try(dt &amp;lt;&amp;lt; rename column group( grp, new_name );)
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works fine with basic grouped columns, but falls over if there's an inherited group from a Link Reference:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Cities.jmp" );
dt_state = Open( "$SAMPLE_DATA/State Abbreviations.jmp" );

//Need more than 1 column
dt_state &amp;lt;&amp;lt; New Column( "Dummy", Numeric, "Continuous", Format( "Best", 12 ));

//Link Tables
dt_state:Abbreviations &amp;lt;&amp;lt; Set Property( "Link ID", 1 );
dt:State &amp;lt;&amp;lt; Set Property("Link Reference", Reference Table(dt_state));

/*//Use if already existing
dt = Data Table ("Cities");
dt_state = Data Table( "State Abbreviations" );
*/

dt &amp;lt;&amp;lt; group columns( "xy", {:X, :y} );
dt &amp;lt;&amp;lt; group columns( "pollutants", :Ozone :: :Lead );

match_col = "X";
new_name = "coordinates";

groups_list = dt &amp;lt;&amp;lt; get column groups names;
show(groups_list);

For Each({grp, ig}, groups_list,
	cols = dt &amp;lt;&amp;lt; get column group( grp );
	show(cols);
	For Each ({column, ic}, cols,
		show(column);
		colname = column &amp;lt;&amp;lt; Get Name;
		If(colname == match_col,
			try(dt &amp;lt;&amp;lt; rename column group( grp, new_name );)
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Firstly, the &lt;CODE class="language-jsl"&gt;&amp;lt;&amp;lt; Get Name&lt;/CODE&gt; function errors on :Ozone, which worked fine in the simpler example.&lt;/P&gt;
&lt;P&gt;Even if that error is resolved, the linked column looks different in the Log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;column = :Y;
column = Referenced Column(&lt;STRONG&gt;"U.S. States[State]"&lt;/STRONG&gt;, Reference(Column(:State), Reference(Column(:U.S. States))));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How do extract the text name? i.e&amp;nbsp;&lt;STRONG&gt;"U.S. States[State]"&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Mar 2026 13:56:23 GMT</pubDate>
    <dc:creator>EOwl</dc:creator>
    <dc:date>2026-03-13T13:56:23Z</dc:date>
    <item>
      <title>Return the Name of a referenced column</title>
      <link>https://community.jmp.com/t5/Discussions/Return-the-Name-of-a-referenced-column/m-p/935242#M109100</link>
      <description>&lt;P&gt;I'm writing a helper function that renames the a column group if it contains a particular column name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Cities.jmp" );

/*//Use if already existing
dt = Data Table ("Cities");
*/

dt &amp;lt;&amp;lt; group columns( "xy", {:X, :y} );
dt &amp;lt;&amp;lt; group columns( "pollutants", :Ozone :: :Lead );

match_col = "X";
new_name = "coordinates";

groups_list = dt &amp;lt;&amp;lt; get column groups names;
show(groups_list);

For Each({grp, ig}, groups_list,
	cols = dt &amp;lt;&amp;lt; get column group( grp );
	show(cols);
	For Each ({column, ic}, cols,
		show(column);
		colname = column &amp;lt;&amp;lt; Get Name;
		If(colname == match_col,
			try(dt &amp;lt;&amp;lt; rename column group( grp, new_name );)
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works fine with basic grouped columns, but falls over if there's an inherited group from a Link Reference:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Cities.jmp" );
dt_state = Open( "$SAMPLE_DATA/State Abbreviations.jmp" );

//Need more than 1 column
dt_state &amp;lt;&amp;lt; New Column( "Dummy", Numeric, "Continuous", Format( "Best", 12 ));

//Link Tables
dt_state:Abbreviations &amp;lt;&amp;lt; Set Property( "Link ID", 1 );
dt:State &amp;lt;&amp;lt; Set Property("Link Reference", Reference Table(dt_state));

/*//Use if already existing
dt = Data Table ("Cities");
dt_state = Data Table( "State Abbreviations" );
*/

dt &amp;lt;&amp;lt; group columns( "xy", {:X, :y} );
dt &amp;lt;&amp;lt; group columns( "pollutants", :Ozone :: :Lead );

match_col = "X";
new_name = "coordinates";

groups_list = dt &amp;lt;&amp;lt; get column groups names;
show(groups_list);

For Each({grp, ig}, groups_list,
	cols = dt &amp;lt;&amp;lt; get column group( grp );
	show(cols);
	For Each ({column, ic}, cols,
		show(column);
		colname = column &amp;lt;&amp;lt; Get Name;
		If(colname == match_col,
			try(dt &amp;lt;&amp;lt; rename column group( grp, new_name );)
		)
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Firstly, the &lt;CODE class="language-jsl"&gt;&amp;lt;&amp;lt; Get Name&lt;/CODE&gt; function errors on :Ozone, which worked fine in the simpler example.&lt;/P&gt;
&lt;P&gt;Even if that error is resolved, the linked column looks different in the Log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;column = :Y;
column = Referenced Column(&lt;STRONG&gt;"U.S. States[State]"&lt;/STRONG&gt;, Reference(Column(:State), Reference(Column(:U.S. States))));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How do extract the text name? i.e&amp;nbsp;&lt;STRONG&gt;"U.S. States[State]"&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2026 13:56:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Return-the-Name-of-a-referenced-column/m-p/935242#M109100</guid>
      <dc:creator>EOwl</dc:creator>
      <dc:date>2026-03-13T13:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Return the Name of a referenced column</title>
      <link>https://community.jmp.com/t5/Discussions/Return-the-Name-of-a-referenced-column/m-p/935277#M109103</link>
      <description>&lt;P&gt;Most likely you are running into issues as JMP is referring to wrong data table. My suggestion is to ALWAYS use explicit column references -&amp;gt; convert your column (references) &lt;STRONG&gt;always&lt;/STRONG&gt; to strings and then use different formats as needed. In your case something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Cities.jmp");
dt_state = Open("$SAMPLE_DATA/State Abbreviations.jmp");

dt_state &amp;lt;&amp;lt; New Column("Dummy", Numeric, "Continuous", Format("Best", 12));

dt_state:Abbreviations &amp;lt;&amp;lt; Set Property("Link ID", 1);
dt:State &amp;lt;&amp;lt; Set Property("Link Reference", Reference Table(dt_state));

dt &amp;lt;&amp;lt; group columns("xy", {:X, :y});
dt &amp;lt;&amp;lt; group columns("pollutants", :Ozone :: :Lead);

match_col = "X";
new_name = "coordinates";

groups_list = dt &amp;lt;&amp;lt; get column groups names;

For Each({grp, ig}, groups_list,
	cols = Transform Each({colweirdness}, dt &amp;lt;&amp;lt; get column group(grp), AsColumn(dt, colweirdness) &amp;lt;&amp;lt; get name);
	For Each({colname, ic}, cols,
		If(colname == match_col,
			try(dt &amp;lt;&amp;lt; rename column group(grp, new_name));
		)
	);	
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2026 17:06:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Return-the-Name-of-a-referenced-column/m-p/935277#M109103</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-03-13T17:06:43Z</dc:date>
    </item>
  </channel>
</rss>

