简体   繁体   English

在Excel中具有最大条件的求和产品

[英]Sumproduct with max condition in excel

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 我的问题是sumproduct的第一部分数组

NUMBERVALUE(RIGHT(Sheet1!A:A,2))=MAX(NUMBERVALUE(Sheet1!A:A)))

The column A contain the below kind of values: A列包含以下类型的值:

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. 对于每一行,如果它是整列中的最后一个月,我想对月份设置一个条件,因此,其想法是获取正确的2位数字的最大值,并针对每一行将正确的2位数字与最大值进行比较整列。

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 乔治·萨巴格

I don't think you are very close to the solution. 我认为您离解决方案不是很近。

  1. From "2016/8" what do you think, the rightmost 2 digits will be? 从“ 2016/8”开始,您认为最右边的2位数字是?
  2. Even NUMBERVALUE will result in #VALUE error in cell A1 = "Till_Date" - rightmost 2 = "te" 即使是NUMBERVALUE也会在单元格A1 =“ Till_Date”-最右边2 =“ te”中导致#VALUE错误
  3. In your MAX(NUMBERVALUE(Sheet1!A:A)) NUMBERVALUE will result in #VALUE error for each cell in A1:A7 since all are text. 在您的MAX(NUMBERVALUE(Sheet1!A:A))由于所有都是文本,因此NUMBERVALUE会导致A1:A7每个单元格出现#VALUE错误。 So MAX is #VALUE error also. 因此MAX也是#VALUE错误。

Problem 1 is solvable by calculating the position of the "/" and taking the number after that. 通过计算“ /”的位置并获取其后的数字,可以解决问题1。

Problems 2 and 3 are solvable only by excludig the errors. 问题2和3只能通过排除错误来解决。 But IFERROR does not work within the matrix context produced by SUMPRODUCT . 但是IFERRORSUMPRODUCT生成的矩阵上下文中不起作用。 For this a real array formula is needed. 为此,需要一个真实的数组公式。

So maybe 所以也许

{=SUM(IF(IFERROR(--RIGHT(Sheet1!A:A,LEN(Sheet1!A:A)-FIND("/",Sheet1!A:A)),0)=MAX(IFERROR(--RIGHT(Sheet1!A:A,LEN(Sheet1!A:A)-FIND("/",Sheet1!A:A)),0)),IF(Sheet1!AG:AG=A9,Sheet1!AA:AA)))}

will work for you. 将为您工作。

This is an array formula. 这是一个数组公式。 Input it into the cell without the curly brackets and press [Ctrl]+[Shift]+[Enter] to confirm. 将其输入到没有大括号的单元格中,然后按[Ctrl] + [Shift] + [Enter]确认。 The curly brackets will then appear automatically. 大括号将自动出现。

Using the whole Sheet1!A:A range this will be of very bad performance. 使用整个Sheet1!A:A范围,这将是非常糟糕的性能。 So you should shrink the range. 因此,您应该缩小范围。 Sheet1!$A$1:$A$10000 for example. Sheet1!$A$1:$A$10000 Same with Sheet1!$AG$1:$AG$10000 and Sheet1!$AA$1:$AA$10000 . Sheet1!$AG$1:$AG$10000Sheet1!$AA$1:$AA$10000

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM