<?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 Fill empty cells based on evaluating of value different column in rows above in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614071#M81412</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following problem:&lt;/P&gt;&lt;P&gt;I want to fill cells via a formula or script in Column "Parent List" absed on next n-1 value in column Level:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fill emty cell (Column „Parent List“, Row 10):&lt;/P&gt;&lt;P&gt;•In row with emty cell go to Level column containing&amp;nbsp; value „4“&lt;/P&gt;&lt;P&gt;•Calculate n-1 („3“)&lt;/P&gt;&lt;P&gt;•Find next row above that contains value n-1 (3), which is row No 9. Copy character (7P61G05) of Material column into emty cell (Parten List, Row 10):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Engelke_0-1679300074523.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/51244iD54277D932597044/image-size/large?v=v2&amp;amp;px=999" role="button" title="Engelke_0-1679300074523.png" alt="Engelke_0-1679300074523.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Fill all emty cells accordingly.&lt;/P&gt;&lt;P&gt;Additionally there might occur the following sepcial case:&lt;/P&gt;&lt;P&gt;Numbering goes down: still select row&amp;nbsp; with n-1 value in cell&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Engelke_1-1679300149696.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/51245iEC1BA8C41191BA0B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Engelke_1-1679300149696.png" alt="Engelke_1-1679300149696.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;i hope anyone can solve that! Thanks you in advance,&lt;/P&gt;&lt;P&gt;Matthias&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jun 2023 16:27:18 GMT</pubDate>
    <dc:creator>Engelke</dc:creator>
    <dc:date>2023-06-08T16:27:18Z</dc:date>
    <item>
      <title>Fill empty cells based on evaluating of value different column in rows above</title>
      <link>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614071#M81412</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following problem:&lt;/P&gt;&lt;P&gt;I want to fill cells via a formula or script in Column "Parent List" absed on next n-1 value in column Level:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fill emty cell (Column „Parent List“, Row 10):&lt;/P&gt;&lt;P&gt;•In row with emty cell go to Level column containing&amp;nbsp; value „4“&lt;/P&gt;&lt;P&gt;•Calculate n-1 („3“)&lt;/P&gt;&lt;P&gt;•Find next row above that contains value n-1 (3), which is row No 9. Copy character (7P61G05) of Material column into emty cell (Parten List, Row 10):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Engelke_0-1679300074523.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/51244iD54277D932597044/image-size/large?v=v2&amp;amp;px=999" role="button" title="Engelke_0-1679300074523.png" alt="Engelke_0-1679300074523.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Fill all emty cells accordingly.&lt;/P&gt;&lt;P&gt;Additionally there might occur the following sepcial case:&lt;/P&gt;&lt;P&gt;Numbering goes down: still select row&amp;nbsp; with n-1 value in cell&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Engelke_1-1679300149696.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/51245iEC1BA8C41191BA0B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Engelke_1-1679300149696.png" alt="Engelke_1-1679300149696.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;i hope anyone can solve that! Thanks you in advance,&lt;/P&gt;&lt;P&gt;Matthias&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:27:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614071#M81412</guid>
      <dc:creator>Engelke</dc:creator>
      <dc:date>2023-06-08T16:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Fill empty cells based on evaluating of value different column in rows above</title>
      <link>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614083#M81414</link>
      <description>&lt;P&gt;Could you provide data table with the data and one column which contains correct values?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 08:31:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614083#M81414</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-03-20T08:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Fill empty cells based on evaluating of value different column in rows above</title>
      <link>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614161#M81419</link>
      <description>&lt;P&gt;Yes of course, thank you. In column "Desired Column" I copied the cells from "Material" column that I would expect the script should insert, depending on values in column "Level!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 10:18:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614161#M81419</guid>
      <dc:creator>Engelke</dc:creator>
      <dc:date>2023-03-20T10:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Fill empty cells based on evaluating of value different column in rows above</title>
      <link>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614268#M81431</link>
      <description>&lt;P&gt;If I'm understanding correctly, this JSL should do what you're looking for:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/*JMP STATISTICAL DISCOVERY LLC (“JMP”) PERMITS THE USE OF THIS COMPUTER SOFTWARE CODE (“CODE”) ON AN AS-IS BASIS AND AUTHORIZES YOU TO USE THE CODE SUBJECT TO THE TERMS LISTED HEREIN.  BY USING THE CODE, YOU AGREE TO THESE TERMS.  YOUR USE OF THE CODE IS AT YOUR OWN RISK.  JMP MAKES NO REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRIGEMENT, AND TITLE, WITH RESPECT TO THE CODE.
You may use the Code solely as part of a software product you currently have licensed from JMP, JMP’s parent company SAS Institute Inc. (“SAS”), or one of JMP’s or SAS’s subsidiaries or authorized agents (the “Software”), and not for any other purpose.  The Code is designed to add functionality to the Software but has not necessarily been tested.  Accordingly, JMP makes no representation or warranty that the Code will operate error-free.  JMP is under no obligation to maintain, support, or continue to distribute the Code.
Neither JMP nor its licensors shall be liable to you or any third-party for any general, special, direct, indirect, consequential, incidental, or other damages whatsoever arising out of or related to your use or inability to use the Code, even if JMP has been advised of the possibility of such damages.  Except as otherwise provided above, the Code is governed by the same agreement that governs the Software.  If you do not have an existing agreement with JMP or SAS governing the Software, you may not use the Code.
JMP and all other JMP Statistical Discovery LLC product or service names are registered trademarks or trademarks of JMP Statistical Discovery LLC in the USA and other countries.  ® indicates USA registration.  Other brand and product names are registered trademarks or trademarks of their respective companies.
*/
Names Default To Here( 1 );
dt = Current Data Table();

For Each Row(
	dt,
	If( Row() &amp;gt; 1,
		look_for_n = :Level[Row()] - 1; //find Level - 1
		rows_with_n = dt &amp;lt;&amp;lt; get rows where( :Level == look_for_n ); //get all rows that match
		last_n = rows_with_n[N Items( rows_with_n )]; //get the last of those rows
		:Desired Column = Char( :Material[last_n] ); //put into desired column
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Mar 2023 16:50:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614268#M81431</guid>
      <dc:creator>Jed_Campbell</dc:creator>
      <dc:date>2023-03-20T16:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Fill empty cells based on evaluating of value different column in rows above</title>
      <link>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614602#M81445</link>
      <description>&lt;P&gt;Hello Jed,&lt;/P&gt;&lt;P&gt;This is fantastic! Thank you so much for the great support! There is a small buck still, maybe you can resolve that too?&amp;nbsp;&lt;/P&gt;&lt;P&gt;The script seems to look for the n-1 number further downwards in the Level Column while it should look for the last n-1, in this case Level „3“, that is before the cell to be filled! So it took the wrong characters in cells of row 10 to 14.I created the column „Correct“ were you can see the correct filled cell:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Engelke_0-1679387182575.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/51293i518DBB9B6208161C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Engelke_0-1679387182575.png" alt="Engelke_0-1679387182575.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The script uses characters "D9844" from next upcoming Level 3 instead of "7P61G05" from last Level 3 before the respective row.&lt;/P&gt;&lt;P&gt;I will add the jmp table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance and best regards,&lt;/P&gt;&lt;P&gt;Matthias&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 08:31:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614602#M81445</guid>
      <dc:creator>Engelke</dc:creator>
      <dc:date>2023-03-21T08:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Fill empty cells based on evaluating of value different column in rows above</title>
      <link>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614775#M81466</link>
      <description>&lt;P&gt;Ah, now I understand better, I think, what you're looking for. Here's an updated script, as well as a &lt;A href="https://community.jmp.com/t5/Learning-Center/Introduction-to-the-JMP-Scripting-Language/ta-p/539562" target="_self"&gt;link to the free and excellent online JMP Scripting course&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/*JMP STATISTICAL DISCOVERY LLC (“JMP”) PERMITS THE USE OF THIS COMPUTER SOFTWARE CODE (“CODE”) ON AN AS-IS BASIS AND AUTHORIZES YOU TO USE THE CODE SUBJECT TO THE TERMS LISTED HEREIN.  BY USING THE CODE, YOU AGREE TO THESE TERMS.  YOUR USE OF THE CODE IS AT YOUR OWN RISK.  JMP MAKES NO REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRIGEMENT, AND TITLE, WITH RESPECT TO THE CODE.
You may use the Code solely as part of a software product you currently have licensed from JMP, JMP’s parent company SAS Institute Inc. (“SAS”), or one of JMP’s or SAS’s subsidiaries or authorized agents (the “Software”), and not for any other purpose.  The Code is designed to add functionality to the Software but has not necessarily been tested.  Accordingly, JMP makes no representation or warranty that the Code will operate error-free.  JMP is under no obligation to maintain, support, or continue to distribute the Code.
Neither JMP nor its licensors shall be liable to you or any third-party for any general, special, direct, indirect, consequential, incidental, or other damages whatsoever arising out of or related to your use or inability to use the Code, even if JMP has been advised of the possibility of such damages.  Except as otherwise provided above, the Code is governed by the same agreement that governs the Software.  If you do not have an existing agreement with JMP or SAS governing the Software, you may not use the Code.
JMP and all other JMP Statistical Discovery LLC product or service names are registered trademarks or trademarks of JMP Statistical Discovery LLC in the USA and other countries.  ® indicates USA registration.  Other brand and product names are registered trademarks or trademarks of their respective companies.
*/

Names Default To Here( 1 );
dt = Current Data Table();
row()=10;
For Each Row(
	dt,
	If( Row() &amp;gt; 1,
		n = row(); //temporary row variable for later
		look_for_n = :Level[Row()] - 1; //find Level - 1
		rows_with_n = dt &amp;lt;&amp;lt; get rows where( :Level == look_for_n &amp;amp; row() &amp;lt; n ); //get all rows that match
		last_n = rows_with_n[N Items( rows_with_n )]; //get the last of those rows
		:Desired Column = Char( :Material[last_n] ); //put into desired column
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Mar 2023 14:17:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/614775#M81466</guid>
      <dc:creator>Jed_Campbell</dc:creator>
      <dc:date>2023-03-21T14:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: Fill empty cells based on evaluating of value different column in rows above</title>
      <link>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/615303#M81505</link>
      <description>&lt;P&gt;Dear Jed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Awesome, the script works perfectly, as intended! Thank you so much for the support. This will be integral part of a script that will provide SAP data in a form that makes the data accessible for material trackings, which is a pain in SAP. My previous script already made JMP quite popular within the company as it is widely used. Thank you also for the scripting course. That is definitely something that I would like to learn better.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So thanks again and best regards,&lt;/P&gt;&lt;P&gt;Matthias&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2023 07:49:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/615303#M81505</guid>
      <dc:creator>Engelke</dc:creator>
      <dc:date>2023-03-22T07:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Fill empty cells based on evaluating of value different column in rows above</title>
      <link>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/615328#M81507</link>
      <description>&lt;P&gt;Below is other idea as it uses a bit different method than Jed does&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

// format data
dt = Open("$DOWNLOADS\Fill empty cells V2.jmp");
Column(dt, "Desired Column")[10::N Rows(dt)] = ""; // set empty values
Column(dt, "Desired Column") &amp;lt;&amp;lt; Set Name("Parent List");

//Column(dt, "Parent List") &amp;lt;&amp;lt; Set Each Value( I would suggest creation of new column
dt &amp;lt;&amp;lt; New Column("ParentListFixed", Character, Nominal, &amp;lt;&amp;lt; Set Each Value(
	As Constant(
		m_levels = :Level &amp;lt;&amp;lt; get values;
		m_materials = :Material &amp;lt;&amp;lt; get values;
	);
	If(Is Missing(:"Parent List"n) &amp;amp; !Is Missing(:Level),
		level_to_search = :Level - 1;
		If(level_to_search &amp;gt; 0,
			row_of_interest = Max(Loc(m_levels[1::Row()], level_to_search));
			m_materials[row_of_interest];
		,
			"";
		);
	,
		:"Parent List"n
	);
));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2023 08:52:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Fill-empty-cells-based-on-evaluating-of-value-different-column/m-p/615328#M81507</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-03-22T08:52:20Z</dc:date>
    </item>
  </channel>
</rss>

