具有excel最大条件的Sumproduct(Sumproduct with max condition in excel)
我有这个公式,但它不起作用
=SUMPRODUCT(--(NUMBERVALUE(RIGHT(Sheet1!A:A,2))=MAX(NUMBERVALUE(Sheet1!A:A,2))),--(Sheet1!AG:AG=A9),(Sheet1!AA:AA))
我的问题是在sumproduct的第一节数组中
NUMBERVALUE(RIGHT(Sheet1!A:A,2))=MAX(NUMBERVALUE(Sheet1!A:A)))
A列包含以下类型的值:
Till_Date 2016/10 2016/10 2016/11 2016/11 2016/12 2016/8
等等..
对于每一行,我想在月份中设置一个条件,如果它是整列中的最后一个月,那么想法是获得正确的2位数的最大值,并且对于每一行,比较正确的2位数字与最大值整栏。
然而它没有工作,感觉我非常接近修复它但无法找到问题
任何援助都将非常感谢。
提前致谢
Georges Sabbagh
I have this formula but it's not working
=SUMPRODUCT(--(NUMBERVALUE(RIGHT(Sheet1!A:A,2))=MAX(NUMBERVALUE(Sheet1!A:A,2))),--(Sheet1!AG:AG=A9),(Sheet1!AA:AA))
My problem is in the first section array of the sumproduct
NUMBERVALUE(RIGHT(Sheet1!A:A,2))=MAX(NUMBERVALUE(Sheet1!A:A)))
The column A contain the below kind of values:
Till_Date 2016/10 2016/10 2016/11 2016/11 2016/12 2016/8
etc..
For each row, I want to set a condition on the month if it is the last month in the whole column, so the idea is to get the max of the right 2 digits and for each row compare right 2 digits with the max value of the whole columns.
However it is not working, feeling that im so close to fix it but could not locate the problem
Any assistance would be much much appreciated.
Thanks in advance
Georges Sabbagh
原文:
最满意答案
您可以在
fun
使用模式匹配:# (fun (Int a) -> a > 0) (Int 1);; Warning 8: this pattern-matching is not exhaustive. Here is an example of a value that is not matched: Fraction _ - : bool = true
如果传入
Fraction
显然会引发匹配错误。 如果你想处理这种情况:# (function Int a -> a > 0 | Fraction {numerator = a; denominator = b} -> a/b > 0 ) (Int 1);; - : bool = true
You can use pattern matching in the
fun
:# (fun (Int a) -> a > 0) (Int 1);; Warning 8: this pattern-matching is not exhaustive. Here is an example of a value that is not matched: Fraction _ - : bool = true
Obviously this will raise a match error if you pass in a
Fraction
. If you want to handle that case:# (function Int a -> a > 0 | Fraction {numerator = a; denominator = b} -> a/b > 0 ) (Int 1);; - : bool = true
相关问答
更多-
gasche的回答有很好的建议 。 我将多解释一下开放和封闭的工会。 首先,您需要区分两种联合:基本变体(无反码)和多态变体(带反色)。 基本变体是生成性的:如果您在不同的模块M1和M2定义了两个具有相同构造函数名称的类型,则您有不同的类型。 M1.Foo和M2.Foo是不同的构造函数。 无论你在哪里使用它, `Foo总是相同的构造函数。 除此之外,多态变体可以完成一切基本变体可以完成的工作。 但是,拥有巨大力量会带来极大的复杂性,因此只有在必要和谨慎的情况下才能使用。 多态变体类型描述了该类型可能具有的构 ...
-
做这样的事情的正确方法是做到以下几点: 在orders.mli中写道: (* This define the signature *) module type ORDERING = sig type t val isLess : t -> t -> bool end (* This define a module having ORDERING as signature *) module StringOrdering : ORDERING 编译文件: ocamlc -c ordering.m ...
-
OCaml中的歧视联盟就像一个C联盟和一个枚举。 所以你的一个number类型的例子可以像这样在C中表示: enum number_tag { ZERO, INTEGER, REAL }; union number_value { int i; /* Only access this if tag is INTEGER */ float f; /* Only access this if tag is REAL */ }; struct number { enum num ...
-
boolean和unions具有相似行为的原因是因为编译器将boolean视为文字类型true和false并集,因此type boolean = true | false type boolean = true | false (虽然此定义不明确存在) 行为的原因是通过设计条件类型分布在联合上。 这是设计的行为,允许实现各种强大的功能。 您可以在此处详细了解该主题 如果您不希望条件分布在联合上,则可以在元组中使用该类型(这将阻止该行为) class MyGeneric
{ } type Replac ... -
联合和相交类型只是将类型视为值集(主要是无限集)。 如果这就是你如何考虑类型,那么对集合进行的任何操作都可以应用于类型(值集),以创建一个新类型(一组值),至少在概念上。 在某种意义上,联合类型与总和类型相似,您似乎很熟悉。 事实上,我经常听到描述为“歧视联盟”类型的总和类型。 基本的区别在于像(Haskell符号) data FooBar = Foo Integer | Bar String的和类型 data FooBar = Foo Integer | Bar String允许您判断给定的FooBar值 ...
-
因为你需要声明一个对象可以返回多种类型中的一种(在你的情况下是一个int或str ,或者在另一个例子str或NoneType ),所以只有当你使用静态类型语言时才需要联合输入。 Python只处理对象 ,因此永远不需要考虑'联合类型'。 如果程序员想要为不同的结果返回不同的类型,那么Python函数会返回他们返回的结果,然后这是他们的选择。 那么选择是一个架构选择,对Python解释器没有任何影响(所以这里没有什么可以'测试')。 Python 3.5确实引入了用于创建可选类型提示的标准,并且该标准包括Un ...
-
OCaml已经知道它们是相同的定义 - 除非你做一些奇怪的事情来隐藏抽象类型,它会将StringSet.elt list和string list视为相同的类型。 OCaml already knows that they are identically defined - unless you're doing something strange to hide the types beind an abstraction, it will treat a StringSet.elt list and st ...
-
在打字稿中命名联合类型(Name Union Types in Typescript)[2022-12-02]
查看类型别名 type FirstOrSecond = FirstType | SecondType; Look at type aliases type FirstOrSecond = FirstType | SecondType; -
OCaml联合类型(OCaml union types)[2023-05-30]
您可以在fun使用模式匹配: # (fun (Int a) -> a > 0) (Int 1);; Warning 8: this pattern-matching is not exhaustive. Here is an example of a value that is not matched: Fraction _ - : bool = true 如果传入Fraction显然会引发匹配错误。 如果你想处理这种情况: # (function Int a -> a > 0 | Fraction {n ... -
OCaml序列化与类型(OCaml serialization with types)[2021-12-27]
如果你需要的只是存储类型名,那么你可以使用typerep库来检索它们,然后调整sexp转换器来处理这些信息。 另一种选择是将数据实际存储为有效的OCaml字符串,并使用编译器库加载它,即实际解析和评估。 在这种情况下,您可以存储您想要的类型或任何内容。 您可能会发现odn库对于将数据转储为OCaml非常有用。 If all that you need is to store typenames, then you can use typerep library, to retrieve them, and ...