如何过滤以显示最后 n 个项目/值?让我们使用半导体能力样本数据表作为背景。
列lot_id有13个级别。
假设我想在IMR控制图中仅显示数据表中最后一批或最后5批的数据。除了手动滚动lot_id列表并手动选择最后5批数据外,还有其他优雅的方法来执行这种最后n次筛选吗?
或者,我的数据表中有多年的过程传感器数据。我只想绘制最近六个月的数据。
基础数据分析与建模质量与工艺工程回复:如何过滤以显示最后 n 个项目/值?对于第二个,您可以使用数据过滤器

您可能希望创建 YEAR-MONTH 列以使选择更容易一些
对于第一个问题,顺序是否仅基于数据表的行顺序?对于半导体能力,它们是按字母顺序排列的,因此您可以使用数据过滤器。

回复:如何过滤以显示最后 n 个项目/值?我将使用这些来创建分类列来标记最近的 xx 天、月份、年份,并在数据过滤器中使用它。
If( :Date >= Date DMY( 1, Month( Col Max( :Date ) ), Year( Col Max( :Date ) ) - 1 ),
"Yes",
"No"
)
If( Col Max( :Date ) - :Date <= In Days( 30 ),
"latest 30 days"
)
您可以修改最近 6 个月的
If(
:Date >= Date DMY( 1, Month( Col Max( :Date ) ), Year( Col Max( :Date ) ) )
-In Years( 0.5 ),
"Yes",
"No"
)
用于标记最新的X标签
我将用它作为最新 2 个批次 ID/周期的示例。
1. 按编号重新分配批次或周期
If( Row() == 1,
1,
If( :Start Date == Lag( :Start Date ),
Lag( :cycle ),
Lag( :cycle ) + 1
)
)
或者这个
If( Row() == 1,
1,
If( :lot ID == Lag( :lot ID ),
Lag( :cycle 2 ),
Lag( :cycle 2 ) + 1
)
)
然后,创建此公式来标记最新的 xx ID 或周期(本例中为 2)
If( Col Max( :cycle ) - :cycle < 2,
"latest 2 cycles"
)
或者,您可以修改此脚本以在您的数据表上运行。
但是,每次数据更新时都需要重新运行此脚本。因此,我更喜欢上面的那个。
last_no = 2;
// Define your column names
timestampCol = "Start Date"; // Replace with your actual timestamp column name
categoryCol = "lot ID"; // Replace with your actual category column name
// Reference the current data table
dt = Current Data Table();
// Create a summary table with the latest timestamp per category
dtSummary = dt << Summary(
Group( column(categoryCol) ),
Max( column(timestampCol) ),
Link to original data table(0),
Output Table Name("LatestPerCategory")
);
// Sort the summary table by latest timestamp descending
dtSummary << Sort(
By( column("Max(" || timestampCol || ")") ),
Order(Descending),
Replace Table(1)
);
// Get the top 2 categories
latestCategories = {};
For( i = 1, i <= last_no, i++,
Insert Into( latestCategories, dtSummary:lot ID[i] )
);
// Add a new column to flag the latest 5 categories
dt << New Column("Is Latest " ||char(last_no),
Character,
Formula( If( Contains( latestCategories, :lot ID ), "Yes", "No" ) )
);
// Optional: Close the summary table
Close( dtSummary, NoSave );
这是我的测试数据

回复:如何过滤以显示最后 n 个项目/值?对于“最后 5 手”,您可以使用 Rank Reverse:

每个“站点”甚至可能最后有 5 个地段 - 就像屏幕截图中那样?

有点令人惊讶:x 轴没有根据数据过滤器设置进行调整。
-> 大量空白
回复:如何过滤以显示最后 n 个项目/值?我使用了“Last.6.Months False/True”公式来创建子集。使用子集而不是过滤器,这样控制图中的子组就不会包含“Last.6.Months == 0”的案例。 
Names Default To Here( 1 );
dt = Current Data Table();
Last.6.Months.Data = dt << Subset( Filtered Rows(:Running? == 1 & :Last.6.Months == 1));
Last.6.Months.Data << Set Name("Last.6.Months.Data");
回复:如何过滤以显示最后 n 个项目/值?贾莫:
谢谢!我之前不知道“排名倒序”功能。我下周会试试。
是的,x 轴问题就是我使用子集而不是数据过滤器的原因。
回复:如何过滤以显示最后 n 个项目/值?事实上,您是对的——必要的功能尚不可用。
让我们从我的错误中吸取教训:
Col Rank 根据行数进行计数 - 而不是根据批次进行计数。
因此每个晶圆都会有自己的编号。->这不是你想要的。
对不起。
但有一个美好的前景:
在版本 19 中,JMP 将获得新功能:)
为 Ranking Tie 和 Col Rank 函数添加密集排名

目前,没有一键式选项来计算唯一反向分数。
解决方法:
JMP19 中将新增另一个功能: Col N 类别 (:green_heart:)
这使我们能够通过以下方式计算反向唯一分数:
(Col N Unique( :lot_id ) - Col N Unique( :lot_id )) + 1
@jthi ,合作很愉快:)
回复:如何过滤以显示最后 n 个项目/值?或者,可以手动添加唯一反向分数:

通过自定义函数
Add Custom Functions(
New Custom Function(
"COL",
"Score Unique_reverse_addExpr",
Function( {value},
Col N Unique( value) - Col Score (value) +1
),
<
<FORMULA category=""></FORMULA>
<BR /> <BR /> <P>但有以下限制:</P>
<UL>
<LI>缺少分组选项</LI>
<LI>必须在公式编辑器中手动添加<FONT face="courier new,courier">表达式()</FONT> (以防止过早评估参数):</LI>
</UL> <P><A href="https://community.jmp.com/t5/Discussions/Fast-Way-to-calculate-quot-nested-quot-Col-aggregations-like-MAD/m-p/888083/highlight/true#M105027" target="_blank">https://community.jmp.com/t5/Discussions/Fast-Way-to-calculate-quot-nested-quot-Col-aggregations-like-MAD/mp/888083/highlight/true#M105027</A> </P> <P><SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_1-1753421633660.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="hogi_1-1753421633660.png" style="width: 324px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="hogi_1-1753421633660.png" style="width: 324px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="hogi_1-1753421633660.png" style="width: 324px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="hogi_1-1753421633660.png" style="width: 324px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="hogi_1-1753421633660.png" style="width: 324px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="hogi_1-1753421633660.png" style="width: 324px;"><span class="lia-inline-image-display-wrapper" image-alt="hogi_1-1753421633660.png" style="width: 324px;"><img src="https://us.v-cdn.net/6038925/uploads/images/78870i815199AB7B6D781F/hogi_1-1753421633660.png" role="button" title="hogi_1-1753421633660.png" alt="hogi_1-1753421633660.png" /></span></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></P>
回复:如何过滤以显示最后 n 个项目/值?我们确实有相当不错的“选择最后”等配置级别,但遗憾的是,这些对于(名义/序数)数据过滤器来说是无法访问的

数据过滤器可以从许多改进中受益,这可能是其中之一,所以也许是这种选择类型的愿望清单项目?
回复:如何过滤以显示最后 n 个项目/值?为 Ranking Tie 和 Col Rank 函数添加密集排名尚未标记为“是的,敬请期待”。
如果运气好的话,他们可以在 9 月份挤进 JMP19 的“反向”密集排名版本;)
回复:如何过滤以显示最后 n 个项目/值?好消息!从 JMP 19.0 开始,控制图生成器新增了一项名为“设置最后 N 个子组”的功能。该功能将调整 X 轴,使其始终显示最近的 N 个子组,无论数据或图表如何更新。
回复:如何过滤以显示最后 n 个项目/值?谢谢你的确认,安妮!
我参加了你在Discovery24的演讲,我觉得你提到了这一点,觉得这是一个进步。期待你的演讲。