简体   繁体   English

使用数组公式Excel的Max函数的总和

[英]Sum of Max functions using an array formula Excel

I'm trying to find a formula that results in the following: 我正在尝试找到导致以下结果的公式:

sum(max(a,b),max(c,d),....)

I tried using =SUM(MAX(0,($D$1:$P$1)-$P$3) as an array formula , but this results in excel taking the maximum of all the entries, instead I want the sum of all maximums. 我尝试使用=SUM(MAX(0,($D$1:$P$1)-$P$3)作为数组公式 ,但这导致excel取所有条目的最大值,而不是我想要所有最大值的总和。

You want to sum a range, say A1:H1 if it's greater than a cell, say H3 . 您要求和一个范围,如果大于一个单元格,则说A1:H1 ,说H3 But you don't want to sum the total, you want to sum the differences between the cells in the range that meet the criteria and the cell they are being compared to, right? 但是,您不想对总数求和,而是要对满足条件的范围中的单元格与要比较的单元格之间的差求和,对吗?

=SUMIF(A1:H1,">"&H3)-(COUNTIF(A1:H1,">"&H3)*H3)

It doesn't need to be entered with ctrl shft entr as sumif is already an array formula . 并不需要与CTRL SHFT ENTR作为输入SUMIF已经是一个阵列式 Adapt to your conditions as needed. 根据需要适应您的条件。

=SUMPRODUCT((D1:P1-P3>0)*(D1:P1-P3))

The first set of parens returns a bunch of Trues and Falses. 第一组parens返回一堆True和False。 When multiplied, Trues are like 1's and Falses are like 0's. 当相乘时,Trues就像1,而Falses就像0。 So when something is below zero, it gets multiplied by zero and becomes zero. 因此,当某物低于零时,它将乘以零,然后变为零。

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

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