如何为具有不相等行的多个变量分配和增加迭代计数?大家好。
我正在尝试创建一个列,该列根据列“Comment = End of Cycle”分配迭代编号(数字和连续),并为相同的 SN 递增它。 每个SN的数据点数量是不一样的。
例如。
对于 SN = "A",第 1-9 行:迭代 =1,第 10-16 行迭代 =2
对于 SN = "B",第 17-27 行:迭代 =1,第 28-36 行迭代 =2 等等...
使用 Row ( ) 函数尝试了一些变体,但没有成功。 有人可以提供一些指导吗?

分析数据表回复:如何为具有不相等行的多个变量分配和增加迭代计数?你好@sumanthcb141977
请尝试以下操作。
New Table( "Untitled",
Add Rows( 36 ),
New Column( "SN",
Character,
"Nominal",
Set Values(
{"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",
"A", "A", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B"}
)
),
New Column( "iteration",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]
)
),
New Column( "iteration count",
Numeric,
"Nominal",
Format( "Best", 9 ),
Formula( Col Cumulative Sum( 1, :SN, :iteration ) )
)
)
如果这不是您要查找的内容,请提供数据表以便更容易解决。
让我们知道它是否有效
回复:如何为具有不相等行的多个变量分配和增加迭代计数?感谢您的回复。 对不起必须更具体。 我不需要迭代计数名称的附加列。 我希望迭代的公式分配一个数字并根据“循环结束”注释递增它。 下面是我希望迭代列看起来像的图像。

我根据请求附加了 jmp 文件。
回复:如何为具有不相等行的多个变量分配和增加迭代计数?@sumanthcb141977
尝试以下。它不稳健,需要按 SN 然后按日期对数据进行排序。
New Table( "Untitled",
Add Rows( 36 ),
New Column( "SN",
Character,
"Nominal",
Set Values(
{"A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",
"A", "A", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B",
"B", "B", "B", "B", "B", "B", "B", "B"}
)
),
New Column( "Comment",
Character,
"Nominal",
Set Values(
{"Cycle", "Cycle", "Cycle", "Cycle", "Cycle", "Cycle", "Cycle", "Cycle",
"End of Cycle", "Cycle", "Cycle", "Cycle", "Cycle", "Cycle", "Cycle",
"End of Cycle", "Cycle", "Cycle", "Cycle", "Cycle", "Cycle", "Cycle",
"Cycle", "Cycle", "Cycle", "Cycle", "End of Cycle", "Cycle", "Cycle",
"Cycle", "Cycle", "Cycle", "Cycle", "Cycle", "Cycle", "Cycle"}
)
),
New Column( "iteration count",
Numeric,
"Nominal",
Format( "Best", 9 ),
Formula(
If(
Row() == 1, 1,
Lag( :SN ) == :SN & Lag( :Comment ) == "Cycle",
Lag( :iteration count ),
Lag( :SN ) == :SN & Lag( :Comment ) == "End of Cycle",
Lag( :iteration count ) + 1,
Lag( :SN ) != :SN & Lag( :Comment ) == "End of Cycle", 1
)
),
Set Selected
)
)
也许其他人有更强大的索引方式。
回复:如何为具有不相等行的多个变量分配和增加迭代计数?@sumanthcb141977
我唯一的其他想法是使用一个额外的表。也许按原样使用新表并将其值用作位置标记。这将允许您有一个表或数值,另一个有类别。这将减少数字和类别之间的硬转换。
回复:如何为具有不相等行的多个变量分配和增加迭代计数?这是公式的其他选项
Col Cumulative Sum(
Col Min(Row(), :SN) == Row() | Lag(:Comment) == "End of Cycle",
:SN
);
回复:如何为具有不相等行的多个变量分配和增加迭代计数?感谢推荐。 数据按 SN 和日期排序,这样更容易。