script for auto column fillingone question about script for column filling. now have one table for a lot kinds of fruit on sale, and a list includes fruit name that sold out already.
how to new create one column (name "sold out?"), and then judge by checking whether the fruit name match with the "sold out fruit list" (apple/durain/…sold out already), if yes, fill in "Y", if no, fill in "N", thanks a lot.
| Fruit Name | sold out? |
| Apple | Y |
| Banana | N |
| durain | Y |
| pear | N |
| orange | N |
Scripting回复:自動列填充腳本這是一個使用JMP列表作為售罄水果的輸入的解決方案。我還通過刪除最後的公式將新列轉換為靜態值,因為如果保存數據表,然後重新打開它,那麼如果不存在以soldList名稱命名的JMP列表,則該列將失敗
Names Default To Here( 1 );
dt = New Table( "Fruit",
New Column( "Fruit Name",
character,
values( {"Apple", "Banana", "Durain", "Pear", "Orange"} )
)
);
soldList = {"Apple", "Durain"};
dt << New Column( "Sold Out",
character,
formula( If( N Rows( Loc( soldList, :Fruit Name ) ), "Y", "N" ) )
);
dt:Fruit Name << delete formula;回复:自動列填充腳本或者您可以使用Contains關鍵字進行檢查。 我正在使用來自JIM的相同示例代碼
Names Default To Here( 1 );
dt = New Table( "Fruit",
New Column( "Fruit Name",
character,
values( {"Apple", "Banana", "Durain", "Pear", "Orange"} )
)
);
soldList = {"Apple", "Durain"};
dt << New Column( "Sold Out",
character,
formula( If( contains(soldList, :Fruit Name), "Y", "N" ) )
);
dt:Fruit Name << delete formula;