如何在“where”条件下使用 Col 最大值公式嗨,我有一个问题,我想制定一个新专栏作为所有其他国家/地区的基准。 如果国家有更多的行,我想以它的最大值为基准。 请参阅下面的示例以进行说明。
数据看起来像这样:
国家价值期
一个 10 201301
一个 30 201301
B 20 201301
C 50 201301
D 40 201301
我想要实现的目标(使用单元格公式):Col Maximum (:value, :period, :country)其中:国家==“A”
输出:
国家价值期基准
10 201301 30
一个 30 201301 30
B 20 201301 30
C 50 201301 30
D 40 201301 30
如您所见,我只想对国家 A 的最大值进行基准测试。
我尝试了 Col Maximum (:value, :period, :country == "A") 并且它会返回 "50"
Col Maximum (:value, :period, :country) 和 Col Maximum (:value, :period, :country == "A") 都返回 "50"
我很确定有一个简单的解决方案!
希望你们能帮忙!
谢谢,谢谢!
回复:如何在“where”条件下使用 Col 最大值公式谢谢。回复:如何在“where”条件下使用 Col 最大值公式Col Maximum() 仅在公式中可行,其中每行的分离结果是输出。要执行您想要的操作,请使用 Summarize() 函数。
看:
帮助==>脚本索引==>总结
回复:如何在“where”条件下使用 Col 最大值公式嗨,马克,
试图按年龄或性别获得最大体重,但在以下脚本中只产生一个值。
按年龄,有 6 个不同的年龄,对于每个年龄,我想计算每个年龄的最大重量。
Names Default To Here( 1 );
Clear Log();
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
max_weight_by_age = Col Max( :weight, :age );
max_weight_by_sex = Col Max( :weight, :sex );
回复:如何在“where”条件下使用 Col 最大值公式我可以将此公式添加到 Big Class 示例数据表中的新列:
Col Max( :weight, :age )
回复:如何在“where”条件下使用 Col 最大值公式嗨,马克,
你能举例说明在使用 col Max 时如何使用 吗?
谢谢。回复:如何在“where”条件下使用 Col 最大值公式请参阅帮助 > 脚本索引 > 函数:

回复:如何在“where”条件下使用 Col 最大值公式谢谢吉姆,我的意思只是总结。 我是怎么做的(两个 jsl 命令):
对列进行总结,创建具有值的新表(列的最小值/最大值/或任何其他统计信息)。
然后我通过匹配行条目使用汇总表更新主表。
我只是好奇 Max col() 命令中是否有条件选项可以识别唯一的列值并消除这个额外步骤的需要。 (将消除额外的表格和 2 个额外的步骤)。
感谢你的帮助。
回复:如何在“where”条件下使用 Col 最大值公式我通常使用 Summarize() 函数而不是 Summary Platform 来轻松确定在列中找到的级别。然后,从那里,您只需生成完成工作所需的公式。
回复:如何在“where”条件下使用 Col 最大值公式假设国家列有多个名称,而我不知道所有可能的值。 如何调整此查询来做到这一点。
我可以通过创建一个汇总表然后更新该表来做到这一点,但这似乎是一种低效的方法,我很好奇是否可以像这样一步完成。
提前致谢。
回复:如何在“where”条件下使用 Col 最大值公式这么晚才回复很抱歉! 感谢您的解决方案!回复:如何在“where”条件下使用 Col 最大值公式鉴于您陈述需求的方式,假设您知道具有多个条目的国家/地区。
dt = Current Data Table();
rowperiod = :Period[Row()];
Max(
:Value[dt << get rows where(
:Country == "A" & :period == rowperiod
)]
);
回复:如何在“where”条件下使用 Col 最大值公式
@hogi写道:有没有一行命令从均值计算中删除女性,但将值写入带有“女性”的相应行?
我的意思是,类似于:
Col Mean( :weight, :age, where( :sex == "M" ) )
?
回复:如何在“where”条件下使用 Col 最大值公式将 If() 应用于等式中的 :weight 列

col Mean( if(:sex=="M", :weight,.), :age)
回复:如何在“where”条件下使用 Col 最大值公式极好的!
所以逻辑 - 当你看到它!
我对自己没有找到这个解决方案感到非常失望。
回复:如何使用带有“where”条件的 Col Maximum Formula嗯,热情高涨过后,我就有点脚踏实地了。
似乎 Col Aggregation 中的if使其变得非常慢 - 尤其是如果 if 内部有字符比较 - 尤其是如果存在 char(num) 转换则速度会加快 2 倍。然后时间会随着表大小的增加而呈二次方增长。
好消息是: Col Median (我大部分时间都在使用)不受此“错误”的影响:)
Col Min、max、mean ...... 有没有什么简单的解决方案?
如果没有,我会写一个愿望来实现一个官方的方法来计算Col xyz与where条件...
如果首先减少数据集( where ),然后聚合( Col xyz ),然后将值分布到所有相应的行上,速度会快得多。

查看更多...Names Default To Here( 1 );
If( Is Empty( mydt ),
mydt = Open( "$SAMPLE_DATA/Big Class.jmp" )
);
trialRun = 0;
tryAgain = Function( {},
trialRun += 1;
Rownumbers = N Rows( mydt );
t1 = HP Time();
mydt << New Column( "col A", Formula( Col Mean( :weight ), :sex ) );
t2 = HP Time();
mydt << New Column( "col B", Formula( Col Mean( If( :age == 12, :weight, . ), :sex ) ) );
t3 = HP Time();
mydt << New Column( "col C", Formula( Col Mean( If( :sex == "M", :weight, . ), :age ) ) );
t4 = HP Time();
mydt << New Column( "col D", Formula( Col Mean( If( Char( :age ) == "12", :weight, . ), :age ) ) );
t5 = HP Time();
mydt << New Column( "col E", Formula( Char( :age ) == "12" ) );
t6 = HP Time();
tt1 = Round( (t2 - t1) / 1000000, 4 );
tt2 = Round( (t3 - t2) / 1000000, 4 );
tt3 = Round( (t4 - t3) / 1000000, 4 );
tt4 = Round( (t5 - t4) / 1000000, 4 );
tt5 = Round( (t6 - t5) / 1000000, 6 );
If( trialRun == 1,
tt1Ref = tt1;
tt2Ref = tt2;
tt3Ref = tt3;
tt4Ref = tt4;
tt5Ref = tt5;
RNref = Rownumbers;
);
tr1 = Round( tt1 / tt1Ref );
tr2 = Round( tt2 / tt2Ref );
tr3 = Round( tt3 / tt3Ref );
tr4 = Round( tt4 / tt4Ref );
tr5 = Round( tt5 / tt5Ref );
RNratio = Round( RowNumbers / RNref );
Wait( 0.1 );
Try( mydt << delete columns( "col A", "col B", "col C", "col D", "col E" ) );
Wait( 0.1 );
mydt = mydt << Concatenate( mydt, mydt, mydt );
Wait( 0.1 );
If(
ex = New Window( "results",
<<TYPE></TYPE></CODE><NOSCRIPT><CODE class=" language-jsl"><DIV class="lia-spoiler-noscript-container"><DIV class="lia-spoiler-noscript-content">名称默认为此处(1);如果(为空(mydt),mydt = 打开(“$SAMPLE_DATA/Big Class.jmp”));trialRun = 0; tryAgain = 函数({},trialRun += 1; 行数 = N 行(mydt);t1 = HP 时间();mydt << 新列(“col A”,公式(Col Mean(:weight),:sex));t2 = HP 时间();mydt << 新列(“col B”,公式(Col Mean(If(:age == 12,:weight,.),:sex)));t3 = HP 时间();mydt << 新列(“col C”,公式(Col Mean(If(:sex == "M", :weight, . ), :age)));t4 = HP 时间();mydt << 新列(“col D”,公式(Col Mean(If(Char(:age)=="12", :weight, . ), :age)));t5 = HP 时间(); mydt << 新列(“col E”,公式(Char(:age)==“12”)); t6 = HP Time(); tt1 = Round((t2 - t1)/ 1000000,4); tt2 = Round((t3 - t2)/ 1000000,4); tt3 = Round((t4 - t3)/ 1000000,4); tt4 = Round((t5 - t4)/ 1000000,4); tt5 = Round((t6 - t5)/ 1000000,6); 如果(trialRun == 1, tt1Ref = tt1; tt2Ref = tt2; tt3Ref = tt3; tt4Ref = tt4; tt5Ref = tt5; RNref = Rownumbers; ); tr1 = Round( tt1 / tt1Ref ); tr2 = Round( tt2 / tt2Ref ); tr3 = Round( tt3 / tt3Ref ); tr4 = Round( tt4 / tt4Ref ); tr5 = Round( tt5 / tt5Ref ); RNratio = Round( RowNumbers / RNref ); Wait( 0.1 ); Try( mydt << 删除列( "col A", "col B", "col C", "col D", "col E" ) ); Wait( 0.1 ); mydt = mydt << 连接( mydt, mydt, mydt ); Wait( 0.1 ); If( ex = New Window( "results", < <TYPE></TYPE></DIV></DIV>
In a previous version I had "ms" in the table instead of seconds. Unfortunately, it's 1000x more severe ...
回复:如何将 Col 最大公式与“where”条件一起使用有趣的问题 - 还在等待答案吗?
有一组帖子有类似的问题如何限制列...聚合功能到特定的子集。
(主要是:将它们限制为非排除行的子集)
计算列平均值,同时限制使用的观测值
JMP10:Col Max() 和 Col Min() 函数返回排除行中的数据
列函数和行状态
想法:
如果对平均身高感兴趣,可以汇总所有行,或者可以分别汇总男性和女性条目。
对于第二个解决方案,解决方案几乎与第一个解决方案一样简单:只需使用额外的 GroupBy 变量来分割所需数据和不需要的数据。
但是,用户通常还需要:这些值应该显示在所有相应的行中(即也适用于女性)。
[原始帖子中带有基准列的示例说明了为什么这种行为是有意义的。]
使用 GroupBy,很容易获得正确的值 - 但如何将它们分布到所有行上。
如果后面有类似查找表的东西列...聚合函数,函数使用相同的标识符
1)将行拆分到不同的组进行聚合(“M”/“F”):
Judy 是女性,Judy 行中的体重应包含在女性平均体重
2) 作为从查找表中读取条目时的索引(“M”/“F”):
朱迪是女性,新专栏应包含女性平均体重在朱迪那一排
因此,男性和女性要么获得相同的值,因为标识符相同 (mean1),要么因为标识符不同而获得不同的值 (mean2)。
因此:
Jmp用户能使用 GroupBy 功能通过以下方式从计算中删除值:
-计算不同的子组有不同的值
- 转储不需要的结果
但后来他得到了
-得到不同的子组有不同的值
免费 - 即使他没有订购此选项(好吧,代码讲述了另一个故事 - 但让我们考虑一下用户想要什么):)
有没有一行命令从平均值计算中删除女性,但将值写入带有“女性”的相应行?
Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt << New Column("mean1", Formula(Col Mean(:weight, :age)));
dt << New Column("mean2", Formula(Col Mean(:weight, :age, :sex)));
dt << New Column("mean2", Formula(If(:sex=="M", Col Mean(:weight, :age, :sex))));
dtM = dt << subset( Rows( dt << get rows where( :sex== "M" ) ), selected columns( 0 ));
dtM << New Column("mean_M", Formula(Col Mean(:weight, :age)));
dt << Update(
With( dtM ),
Match Columns(:age = :age ),
Add Columns from Update Table( :mean_M ),
Replace Columns in Main Table( None )
);
回复:如何将 Col 最大公式与“where”条件一起使用一种加快速度的方法几个数量级(!!!):
而不是非常慢的 Col Mean与 if 语句内的字符比较:
mydt << New Column( "col C", Formula( Col Mean( If( :name=="Robert", :weight, . ), :age ) ) );
使用@cwillden的技巧:使用比较作为 GroupBy 参数:
已解决:回复:获取满足列公式内条件的行 - JMP 用户社区
mydt << New Column( "col C", Formula(if(:name=="Robert" , Col Mean( :weight, :age, :name=="Robert" ),. ) );
将数据分为 2 组:想要的数据和不需要的数据(下面的屏幕截图,@10k 行 -> 速度提高 2000 倍:)
.. 然后通过 Col Mean 聚合之外的 if 语句删除不需要的结果。
与列的比较:性别这种方法会被过度设计;这就是我切换到:姓名比较来说明概念。
这也有点过度设计,但我希望这个想法能变得清晰:)

查看更多...
回复:如何将 Col 最大公式与“where”条件一起使用我刚刚注意到:
- 这个技巧不起作用
:名字==“罗伯特”
似乎是一个特殊情况 - 比较被忽略(在 Jmp 16 和 17.1 中)。
奇怪的 ...
- 带着对新可能性(使用条件(!)作为 GroupBy)和速度改进的热情,我完全错过了我或多或少回到了我开始的地方:带有 Group By 选项的 Col 聚合。
所以,我没有达到我的实际目标:用值填充“其他”行,如下所述:
我如何使用带有“where-quot”的“Col-Maximum-Formula”/mp/571889/highlight/true#M78145
但有一个解决方法:而不是缓慢
New Column( "newcol", Formula(Col Mean( if(:sex=="M",:weight,.), :age ) ));
请注意,slow Col Mean 内只有 Group By 选项
...然后使用快速 Col Median 将值传播到其他行:
New Column( "newcol", Formula(Col Median(If(:sex =="M" ,Col Mean( :weight, :age, :sex),.),:age) ));
另外:这个话题得到了 Jmp 开发团队的一些关注:
Col Median(及其他):添加“Where”选项
@萨姆加德纳写道:
状态更改为:我们喜欢它! (在队列中)...我们致力于改进Where( ) 子句在整个JMP 中的使用方式。
看来很快就会有一个更简单的解决方案来解决这个问题:)
回复:如何使用带有“where”条件的 Col Maximum Formula有趣的事实:
在字符串列表中搜索“M”比将“M”与字符串进行比较要快几个数量级:

Names Default To Here( 1 );
If( Is Empty( mydt ),
mydt = Open( "$SAMPLE_DATA/Big Class.jmp" )
);
tryAgain = Function( {},
write ("\!nrows: ", nrows(mydt),"\!n");
t0 = HP Time();
mydt << New Column( "char=char", Formula( Col Mean( If( :sex == "M", :weight, . ), :age ) ) );
t=(HP Time()- t0)/1000000;
write("char=char: ",t,"\!n");
t0 = HP Time();
mydt << New Column( "contains", Formula( Col Mean( If( contains(Eval List({:sex[]}) ,"M"), :weight, . ), :age ) ) );
t=(HP Time()- t0)/1000000;
write("contains: ",t,"\!n");
If(
ex = New Window( "",
<<TYPE></TYPE><BR />why?!?<BR />Which secret is behind this finding?
回复:如何将列最大值公式与“where”条件一起使用2025 - JMP19 在字符串比较方面实现了显著的速度提升。
凉爽的!
除此之外,建议
col Mean(:weight, :age, where(not(excluded())))
引入此方法是为了转换报表中的列。它变得非常简洁:

另一方面,要找到一个适用于特定聚合条件(例如:sex="M")的正确公式仍然非常困难。
<SPAN class="token function">if<SPAN class="token punctuation">(</SPAN><SPAN class="token punctuation">:</SPAN>sex<SPAN class="token operator">==</SPAN><SPAN class="token string">"M"& not(excluded()),<BR /></SPAN> col Max</SPAN><SPAN class="token punctuation">(</SPAN><SPAN> </SPAN><SPAN class="token function">if</SPAN><SPAN class="token punctuation">(</SPAN><SPAN class="token punctuation">:</SPAN>sex<SPAN class="token operator">==</SPAN><SPAN class="token string">"M"</SPAN><SPAN class="token punctuation">,</SPAN><SPAN> </SPAN><SPAN class="token punctuation">:</SPAN>weight<SPAN class="token punctuation">,</SPAN><SPAN class="token punctuation">.</SPAN><SPAN class="token punctuation">)</SPAN><SPAN class="token punctuation">,</SPAN><SPAN> </SPAN><SPAN class="token punctuation">:</SPAN>age, excluded()<SPAN class="token punctuation">)<BR /> , .<BR />);</SPAN>
类似
col Max(:weight, :age, @excluded, where(:sex=="M"))
可能会有很大帮助。
嗯: 列中位数(及其他):添加“位置”选项:3.5 年才获得 1 个赞?!真奇怪。