<?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: JSL scripting for dynamic column asignment in graph builder in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935326#M109109</link>
    <description>&lt;P&gt;Depending on your use case, you could use tags like already suggested, custom column property, prefixed column names, column groups,... all of the options do have their own pros and cons.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

collist = dt &amp;lt;&amp;lt; Get Column Names("String");

npn_cols = Filter Each({colname}, collist, Starts With(colname, "NPN"));
pnp_cols = Filter Each({colname}, collist, Starts With(colname, "PNP"));

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Variables(X(:SITE), Y(:IVP1), Color(pnp_cols[1])),
	Elements(
		Position(1, 1),
		Points(X, Y(1), Legend(27))
	),
	Elements(
		Position(1, 2),
		Points(X, Y(1), Legend(28)),
		Line(X, Y(2), Y(3), Color(0), Legend(31))
	)
);

filter_cols = npn_cols[1::2];
Insert Into(filter_cols, "SITE");
ldf = gb &amp;lt;&amp;lt; Local Data Filter(
	Conditional,
	Add Filter(
		columns(Eval(filter_cols)),
		Display(filter_cols[1]),
		Display(filter_cols[2]),
		Display(filter_cols[3])
	)
);

cw = gb &amp;lt;&amp;lt; Column Switcher(pnp_cols[1], pnp_cols);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also... is this some sort of hybrid of a community question and a LLM prompt (we are humans here in Community, hopefully)?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 14 Mar 2026 07:09:35 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2026-03-14T07:09:35Z</dc:date>
    <item>
      <title>JSL scripting for dynamic column asignment in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935170#M109091</link>
      <description>&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;I am attempting to create a session script to generate graphs using JMP's Graph Builder. However, a challenge arises because the number of columns in my data varies depending on the period each time the data is updated, which necessitates modifying the Graph Builder script manually for each update.&lt;/P&gt;
&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;To address this, I am considering a method where column names are prefixed (e.g.,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;A_&lt;/CODE&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;B_&lt;/CODE&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;C_&lt;/CODE&gt;). This would allow me to dynamically assign columns: for instance, columns prefixed with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;A_&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;could be directed to the Local Data Filter, those with&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;B_&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to the Column Switcher, and so forth.&lt;/P&gt;
&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;I would like to know how this approach can be implemented in JSL (JMP Scripting Language), as I have not been able to write an effective script myself. You mentioned having an incomplete JSL draft in mind, but it was not included in your prompt. If you can provide the draft, I would be happy to help you refine it or suggest a solution.&lt;/P&gt;
&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;&lt;SPAN&gt;I am also encountering the following error.→［For Each , Bad Argument( colName ), For Each/*###*/(colName, columnNames,...&lt;STRONG&gt;The argument must be a list.&lt;/STRONG&gt;]&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();

A_list = {};
B_list = {};

columnNames = As List(dt &amp;lt;&amp;lt; Get Column Names("String"));

For Each(colName, columnNames,&lt;BR /&gt;
    If(Contains(colName, "A_"),
        Insert Into(A_list, colName)
    );

    If(Contains(colName, "B_"),
        Insert Into(B_list, colName)
    );
);

Graph Builder(
	Variables(
		X( :point ),
		Y( :avg ),
		Y( :stddev ),
		Page( :category ),
		Color(B_list[1])
	),
	Elements(
		Position( 1, 1 ),
		Points( X, Y( 1 ), Legend( 27 ) ),
		Line( X, Y( 2 ), Y( 3 ), Color( 0 ), Legend( 29 ) )
	),
	Elements(
		Position( 1, 2 ),
		Points( X, Y( 1 ), Legend( 28 ) ),
		Line( X, Y( 2 ), Y( 3 ), Color( 0 ), Legend( 31 ) )
	),
	Local Data Filter(
		Conditional,
		Add Filter(
			columns( A_list ),
			Display( A_list[1], N Items( 7 ), Find( Set Text( "" ) ) ),
			Display( A_list[2], N Items( 7 ) ),
			Display( :key, N Items( 12 ) )
		)
	),
	Column Switcher(
		:msr_dt,
		B_list
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Mar 2026 05:07:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935170#M109091</guid>
      <dc:creator>TamedZebra</dc:creator>
      <dc:date>2026-03-13T05:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: JSL scripting for dynamic column asignment in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935183#M109092</link>
      <description>&lt;P&gt;did you consider column tags to "group" the columns?&lt;BR /&gt;this could provide a similar functionality - and it even allows overlapping "groups".&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );
dt:sex &amp;lt;&amp;lt; setProperty( "Tags", {"pick"} );
dt:height &amp;lt;&amp;lt; setProperty( "Tags", {"pick"} );
dt:weight &amp;lt;&amp;lt; setProperty( "Tags", {"pick"} );
cols = dt &amp;lt;&amp;lt; Get Tagged Columns( "pick" );

dt &amp;lt;&amp;lt; Distribution( Column( Eval(cols) ));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;by the way, it's &lt;FONT face="courier new,courier"&gt;for each ({col}, cols, body)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2026 18:04:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935183#M109092</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2026-03-13T18:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: JSL scripting for dynamic column asignment in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935185#M109094</link>
      <description>&lt;DIV class="relative overflow-hidden h-full w-full" dir="ltr"&gt;
&lt;DIV class="h-full w-full [&amp;amp;&amp;gt;div]:!block" data-radix-scroll-area-viewport=""&gt;
&lt;DIV class="flex w-[94%] mx-auto"&gt;
&lt;DIV class="h-full w-full animate-in fade-in-0"&gt;
&lt;DIV class="w-full flex flex-col gap-4 p-2"&gt;
&lt;DIV class="rounded-lg p-4 shadow-md bg-background text-foreground whitespace-pre-wrap text-sm max-w-[calc(100%_-_5rem)] mr-auto relative [&amp;amp;:hover&amp;gt;button]:opacity-100"&gt;
&lt;DIV class="reset flex flex-col gap-1 markdown"&gt;
&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;Thank you for your replying, hogi.&lt;/P&gt;
&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;I had not considered column tags. I will try to revise the script using column tags once again.&lt;/P&gt;
&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;I will reply after doing that.&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 13 Mar 2026 06:54:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935185#M109094</guid>
      <dc:creator>TamedZebra</dc:creator>
      <dc:date>2026-03-13T06:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: JSL scripting for dynamic column asignment in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935326#M109109</link>
      <description>&lt;P&gt;Depending on your use case, you could use tags like already suggested, custom column property, prefixed column names, column groups,... all of the options do have their own pros and cons.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");

collist = dt &amp;lt;&amp;lt; Get Column Names("String");

npn_cols = Filter Each({colname}, collist, Starts With(colname, "NPN"));
pnp_cols = Filter Each({colname}, collist, Starts With(colname, "PNP"));

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Variables(X(:SITE), Y(:IVP1), Color(pnp_cols[1])),
	Elements(
		Position(1, 1),
		Points(X, Y(1), Legend(27))
	),
	Elements(
		Position(1, 2),
		Points(X, Y(1), Legend(28)),
		Line(X, Y(2), Y(3), Color(0), Legend(31))
	)
);

filter_cols = npn_cols[1::2];
Insert Into(filter_cols, "SITE");
ldf = gb &amp;lt;&amp;lt; Local Data Filter(
	Conditional,
	Add Filter(
		columns(Eval(filter_cols)),
		Display(filter_cols[1]),
		Display(filter_cols[2]),
		Display(filter_cols[3])
	)
);

cw = gb &amp;lt;&amp;lt; Column Switcher(pnp_cols[1], pnp_cols);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also... is this some sort of hybrid of a community question and a LLM prompt (we are humans here in Community, hopefully)?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Mar 2026 07:09:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935326#M109109</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-03-14T07:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: JSL scripting for dynamic column asignment in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935516#M109122</link>
      <description>&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;日本語の返答ですが、お許しください（こちらの方が本意が伝わるかと思いまして）。&lt;/P&gt;
&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;JMP learnBotに質問しても解決できなかった事例について、この度、コミュニティの皆様にも共有させていただいております。&lt;/P&gt;
&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;やはり、知見をお持ちの方々のスクリプトの記述方法やアドバイスをいただくことで、私自身のスクリプト技術の向上を図り、さらには身近なJMPユーザーのスキルアップにも貢献したいと考え、このコミュニティを利用させていただいております。&lt;/P&gt;
&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;しかしながら、いつもご丁寧にご回答くださるjthiさんのお気持ちを害してしまったのではないかと案じており、大変申し訳なく思っております。もし、質問の仕方において不躾な点や改善すべき点がございましたら、今後のためにぜひご指摘いただけますと幸いです。&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2026 00:31:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935516#M109122</guid>
      <dc:creator>TamedZebra</dc:creator>
      <dc:date>2026-03-16T00:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: JSL scripting for dynamic column asignment in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935540#M109123</link>
      <description>&lt;P&gt;I wasn't offended by your post but more weirded out as it felt like we are being prompted here. I would clearly suggest separating the prompt if you have used one.&lt;/P&gt;
&lt;P&gt;LearnBot isn't really that good with JSL as it isn't prompted that way. Assistant might be slightly better, but you might get better results if you prompt LLM (such as Claude, preferrably one your company has access to) so it understands what it should be doing (JSL).&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2026 05:59:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935540#M109123</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-03-16T05:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: JSL scripting for dynamic column asignment in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935544#M109124</link>
      <description>&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;Jthiさんのおっしゃる通りで私の中でLLMへのプロンプトとJMPユーザーコミュニティへの投稿の間に明確な区別ができていませんでした。&lt;/P&gt;
&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;今後、LLMへの質問なのか、JMPユーザーコミュニティへの投稿として適切なのか、内容をより精査します。円滑なコミュニケーションのために意識すべき重要な点にご指摘いただき、ありがとうございます。&lt;/P&gt;
&lt;P class="[&amp;amp;:not(&amp;amp;:first-child):has(strong)]:mt-1"&gt;これからもどうぞよろしくお願いいたします。&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2026 07:11:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/935544#M109124</guid>
      <dc:creator>TamedZebra</dc:creator>
      <dc:date>2026-03-16T07:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: JSL scripting for dynamic column asignment in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/937819#M109299</link>
      <description>&lt;P&gt;In case you were looking at how to make the script itself work, here is an updated version that might get you started.&amp;nbsp; I commented a few sections I changed, note that the most complex one involves inserting a list of columns into the local data filter which prompted the Eval( Eval Insert( ) ) functions.&amp;nbsp; You might check out&amp;nbsp;&lt;LI-MESSAGE title="Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute" uid="48998" url="https://community.jmp.com/t5/JSL-Cookbook-Archived/Insert-one-expression-into-another-using-Eval-Insert-Eval-Expr/m-p/48998#U48998" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;to see different options for that.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);

Random reset(1);
msr_dt = New Table( "Example Data",
	Add Rows( 200 ),
	New Column( "A_1", Character, "Nominal", Formula( if(random uniform(1)&amp;lt;0.2,"",Substr( "ABC", floor(Random uniform( 4 )),1) ))),
	New Column( "A_2", Character, "Nominal", Formula( if(random uniform(1)&amp;lt;0.2,"",Substr( "DEF", floor(Random uniform( 4 )),1) ))),
	New Column( "B_1", Character, "Nominal", Formula( if(random uniform(1)&amp;lt;0.2,"",Substr( "GHI", floor(Random uniform( 4 )),1) ))),
	New Column( "B_2", Character, "Nominal", Formula( if(random uniform(1)&amp;lt;0.2,"",Substr( "JKL", floor(Random uniform( 4 )),1) ))),
	New Column( "point", Numeric, "Continuous", Format( "Best", 12 ), Formula( Row() ) ),
	New Column( "avg", Numeric, "Continuous", Format( "Best", 12 ), Formula( Random Normal( 5 ) ) ),
	New Column( "stddev", Numeric, "Continuous", Format( "Best", 12 ), Formula( Random Normal( 0.5 ) ) ),
	New Column( "category", Character, "Nominal", Formula( Char( Floor( Row() / 101 ) ) ), Set Selected ),
	New Column( "key", Character, "Nominal", Formula( Substr( "abcdefghijklmnopqrstufwxyz", floor(Random uniform( 27 )),1) )),
);

A_list = {};
B_list = {};

columnNames = As List(msr_dt &amp;lt;&amp;lt; Get Column Names("String"));

For Each({colName},columnNames,  // change here - note brackets
    If(Contains(colName, "A_"),
        Insert Into(A_list, colName)
    );

    If(Contains(colName, "B_"),
        Insert Into(B_list, colName)
    );
);

Eval(Eval expr(
	Graph Builder(
		Variables(
			X( :point ),
			Y( :avg ),
			Y( :stddev ),
			Page( :category ),
			Color(B_list[1])
		),
		Show Control Panel( 0 ),
		Elements(
			Position( 1, 1 ),
			Points( X, Y( 1 ), Legend( 27 ) ),
			Line( X, Y( 2 ), Y( 3 ), Color( 0 ), Legend( 29 ) )
		),
		Elements(
			Position( 1, 2 ),
			Points( X, Y( 1 ), Legend( 28 ) ),
			Line( X, Y( 2 ), Y( 3 ), Color( 0 ), Legend( 31 ) )
		),
		Local Data Filter(
			Conditional,
			Add Filter(
				columns( Expr( A_list || {"key"} ) ), //this needs to be evaluated before the graph builder function is called
				Display( A_list[1], N Items( 7 ) ), //removed the find term
				Display( A_list[2], N Items( 7 ) ),
				Display( :key, N Items( 12 ) )
			)
		),
		Column Switcher(
			B_list[1], // added reference to specific column here - was the data table
			B_list
		)
	)
));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Mar 2026 21:22:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/937819#M109299</guid>
      <dc:creator>ih</dc:creator>
      <dc:date>2026-03-27T21:22:18Z</dc:date>
    </item>
    <item>
      <title>Re: JSL scripting for dynamic column asignment in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/938836#M109342</link>
      <description>&lt;P&gt;JSL Novice here, so please forgive me if this was asked and answered earlier.&lt;/P&gt;
&lt;P&gt;What I want to do is modify the above Graph Builder script to plot IVP columns vs NPN columns with colors from PNP columns. Enclosed is the modified script (Multiple Column Switcher.jsl) - with 3 column switchers. And I have to manually choose the combinations of IVP, NPN and PNP columns I want. If I know the IVP NPN and PNP columns are all mapped 1 to 1 (i.e. IVP3 vs NPN3 and PNP3 for example), how can I have single column switcher to do that?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2026 16:38:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/938836#M109342</guid>
      <dc:creator>RegressionPony6</dc:creator>
      <dc:date>2026-04-01T16:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: JSL scripting for dynamic column asignment in graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/938840#M109343</link>
      <description>&lt;P&gt;I had simplified version of this in my tips&amp;amp;tricks presentation in discovery summit (&lt;A href="https://community.jmp.com/t5/Abstracts/Skip-Hop-and-JMP-a-Minute-Bite-Sized-JMP-Wisdom-from-a-Super/ec-p/916556#M2292" target="_blank" rel="noopener"&gt;Skip, Hop, and JMP a Minute: Bite-Sized JMP Wisdom from a Super User (2026-EU-30MP-2767)&lt;/A&gt;&amp;nbsp;, tip "Column switchers for everyone (Multiple Column Switchers)")&lt;/P&gt;
&lt;P&gt;This is quite simple way of doing it (do note that NPN has more columns than the rest so it will use incorrect column in that case)&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/Semiconductor Capability.jmp");

collist = dt &amp;lt;&amp;lt; Get Column Names("String");

npn_cols = Filter Each({colname}, collist, Starts With(colname, "NPN"));
pnp_cols = Filter Each({colname}, collist, Starts With(colname, "PNP"));
ivp_cols = Filter Each({colname}, collist, Starts With(colname, "IVP"));

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Variables(X(:NPN1), Y(:IVP1), Color(pnp_cols[1])),
	Elements(
		Position(1, 1),
		Points(X, Y(1), Legend(27))
	),
	Elements(
		Position(1, 2),
		Points(X, Y(1), Legend(28)),
		Line(X, Y(2), Y(3), Color(0), Legend(31))
	)
);


cw1 = gb &amp;lt;&amp;lt; Column Switcher(npn_cols[1], npn_cols);
cw2 = gb &amp;lt;&amp;lt; Column Switcher(pnp_cols[1], pnp_cols);
cw3 = gb &amp;lt;&amp;lt; Column Switcher(ivp_cols[1], ivp_cols);

Eval(EvalExpr(
	post = Function({previousColumn, currentColumn, switcher},
		c2 = Substitute((currentColumn &amp;lt;&amp;lt; get name), "NPN", "PNP");
		c3 = Substitute((currentColumn &amp;lt;&amp;lt; get name), "NPN", "IVP");
		Expr(cw2) &amp;lt;&amp;lt; Set Current(c2);
		Expr(cw3) &amp;lt;&amp;lt; Set Current(c3);
	);
));

handler = cw1 &amp;lt;&amp;lt; Make Column Switch Handler(post);

// might want to hide other column switchers
cw_obs = (Report(gb) &amp;lt;&amp;lt; Top Parent) &amp;lt;&amp;lt; XPath("//ColumnSwitcherContextOutlineBox");
cws = cw_obs &amp;lt;&amp;lt; Get Scriptable Object;
cw_obs[2] &amp;lt;&amp;lt; Visibility("Collapse");
cw_obs[3] &amp;lt;&amp;lt; Visibility("Collapse");

Write();
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Stacked data table and local data filter can also be a good option for things such as this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2026 17:23:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-scripting-for-dynamic-column-asignment-in-graph-builder/m-p/938840#M109343</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-04-01T17:23:44Z</dc:date>
    </item>
  </channel>
</rss>

