<?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: A function to add columns with names that has a prefix in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748474#M92896</link>
    <description>&lt;P&gt;You seem to be creating single column named "Data Usable?" and no columns which have specific prefixes. Generally you would maybe want to change Column() to As Column() inside your Set Each Value but I'm not exactly sure what you are trying to do.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Apr 2024 19:08:50 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-04-22T19:08:50Z</dc:date>
    <item>
      <title>A function to add columns with names that has a prefix</title>
      <link>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748472#M92895</link>
      <description>&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Hi community,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I want to write a function to add columns that have names that has a given prefix, and give values to the columns based on given conditions. This is the script that I have, but it errors out "Unresolved Column". I double checked everything and don't know where went wrong...&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Much appreciated for the help!&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;add_extra_columns = Function({dt, prefix},
	{Default Local},
	dt &amp;lt;&amp;lt; New Column("Data Usable?",
		Numeric,
		"Continuous",
		Format("Best", 12), 
 
 
		Set each value(
			If(
				!Is Missing(
					Column(dt, add_prefix_to_col_name("Image", prefix)),
					If(Column(dt, add_prefix_to_col_name("Status", prefix)) == "Failed",
						0,
						If(
							Is Missing(Column(dt, add_prefix_to_col_name("Area Ratio", prefix)))
							 &amp;amp; Column(dt, add_prefix_to_col_name("Shape", prefix)) != "Square",
							0,
							If(
								Column(dt, add_prefix_to_col_name("Status", prefix)) ==
								"Succeeded" | Column(
									dt,
									add_prefix_to_col_name("Status", prefix)
								) == "Warning",
								1
							)
						)
					)
				)
			)
		)
	)
);
 
 
add_prefix_to_col_name = Function({col_name, prefix}, // folder_path： the "\" at the end of the string is necessary
	{Default Local}, 
 
	If(prefix == "",
		new_name = prefix || col_name,
		new_name = prefix || " " || col_name
	);
 
	Return(new_name);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 22 Apr 2024 19:01:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748472#M92895</guid>
      <dc:creator>DivisiveEagle45</dc:creator>
      <dc:date>2024-04-22T19:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: A function to add columns with names that has a prefix</title>
      <link>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748474#M92896</link>
      <description>&lt;P&gt;You seem to be creating single column named "Data Usable?" and no columns which have specific prefixes. Generally you would maybe want to change Column() to As Column() inside your Set Each Value but I'm not exactly sure what you are trying to do.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 19:08:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748474#M92896</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-04-22T19:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: A function to add columns with names that has a prefix</title>
      <link>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748479#M92898</link>
      <description>&lt;P&gt;Hi Jarmo,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for replying. Sorry that I was not clear with my question. The new column name is just "Data Usable?". But the part within the "Set each value" is giving me problems. I want to set the value of the new column name based on column names that has a certain prefix.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 20:34:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748479#M92898</guid>
      <dc:creator>DivisiveEagle45</dc:creator>
      <dc:date>2024-04-22T20:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: A function to add columns with names that has a prefix</title>
      <link>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748482#M92901</link>
      <description>&lt;P&gt;Try changing Column() to As Column() or Column()[]&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Column(dt, add_prefix_to_col_name("Image", prefix)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;AsColumn(dt, add_prefix_to_col_name("Image", prefix)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Column(dt, add_prefix_to_col_name("Image", prefix)[]&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Apr 2024 20:48:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748482#M92901</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-04-22T20:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: A function to add columns with names that has a prefix</title>
      <link>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748490#M92904</link>
      <description>&lt;P&gt;Unfortunately, all do not work, regardless AsColumn or Column()[]&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 21:16:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748490#M92904</guid>
      <dc:creator>DivisiveEagle45</dc:creator>
      <dc:date>2024-04-22T21:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: A function to add columns with names that has a prefix</title>
      <link>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748523#M92919</link>
      <description>&lt;P&gt;Then I would try to simplify your function&amp;nbsp;add_extra_columns. Make it have only one if statement and after you get that working start adding more.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 05:31:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/A-function-to-add-columns-with-names-that-has-a-prefix/m-p/748523#M92919</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-04-23T05:31:58Z</dc:date>
    </item>
  </channel>
</rss>

