为什么max函数会聚合?

Why does the max function aggregate?

我想 return 块中一列的最大值,其值为 13 个周期。

Max([CountVariable]) returns 每个周期的值。 Max([CountVariable] forAll([Period)) returns 所有值的总和。

这就是我得到的:

Period CountVariable Max([CountVariable])  Max([CountVariable] forAll([Period))
1      10            10                    45
2      15            15                    45
3      20            20                    45

这就是我想要的:

Period CountVariable Max
1      10            20
2      15            20
3      20            20

你很接近。要获得所有期间的最大值,您需要设置要在 输出上下文 中评估的变量。您可以通过在 Max() 函数之外指定上下文运算符 (ForAll) 来执行此操作。所以:

Max([CountVariable]) forAll([Period])