简体   繁体   English

EXCEL Array SUM IF多个条件的唯一组合

[英]EXCEL Array SUM IF unique combinations of multiple criteria

Is it possible to create an array formula based on a table where it searches for distinct combinations of data before summing? 是否可以基于表创建数组公式,在求和之前先搜索不同的数据组合? Here is some sample data: 以下是一些示例数据:

   |    A     |     B     |     C     |     D     |
---------------------------------------------------
 1 | 1 Jun    | Charlie   | D         | 1.3       |
 2 | 1 Jun    | Charlie   | N         | 1.4       |
 3 | 1 Jun    | Dave      | D         | 1.3       |
 4 | 2 Jun    | Charlie   | N         | 0.6       | 
 5 | 2 Jun    | Dave      | D         | 1.5       |

What I'd like the array formula to be able to do is look at the table, ignore column B and tell me which distinct rows (A, C and D or more criteria) and sum column D if they are unique. 我希望数组公式能够执行的操作是看表,忽略列B,并告诉我哪些不同的行(A,C和D或更多条件),并对列D求和(如果它们是唯一的)。 In this example, it should not sum Row 3 because on 1 Jun, "D" already has a 1.3. 在此示例中,它不应求和第3行,因为在6月1日,“ D”已经具有1.3。

PivotTables and VBA are out as I am designing this for the lowest level user on super restrictive computers. 我为超级限制性计算机上的最低级别用户设计此数据透视表和VBA时,已经淘汰了。

EDIT: Picture of expected results, changed sample data to reflect results. 编辑:预期结果的图片,更改了样本数据以反映结果。 预期成绩

Kind of the data I am looking for.... I replaced the ID with the LName to visualize. 我正在寻找的数据种类。...我用LName替换了ID以进行可视化。 I need to exclude individuals and get only aircraft hours by their modes. 我需要排除个人,仅根据他们的模式获得飞行时间。 You can see toward the bottom of the image, 2 people are on one aircraft. 您会看到图像的底部,一架飞机上有2个人。 I used MAX to keep it from SUMming it up and skewing the hours. 我使用MAX来避免累加和浪费时间。

The levels on the left are by Date, Aircraft, Flight Number, then Person. 左边的级别是按日期,飞机,航班号,然后是人员。 I need to aggregate the hours down to the Flight Number of each date. 我需要将小时数汇总为每个日期的航班号。

数据透视表

The original formula is 原来的公式是

=SUM((FLTD_HRS)*(FLTD_DATE>=$D$3)*(FLTD_DATE<=$D$4)*(IF(FLTD_ACFT_MDS=CONFIG!$F$8,1,0)))

however, as it is, does not get me unique flights. 但是,实际上并不能为我提供独特的航班。 I'd prefer an array formula to a PivotTable.... XD 与数据透视表相比,我更喜欢数组公式。

  1. Create a table with the unique combos of A, C, and D. This works assuming finite or at least non-changing but you can also just add every combination you could possibly have and add an IF(row="","",x) to the formula to not show. 创建一个具有A,C和D唯一组合的表。此方法在假设有限或至少不变的情况下起作用,但您也可以添加可能的所有组合并添加IF(row =“”,“”, x)公式不显示。
  2. You can add a new column (E) to your first table and then lookup the value in the new table or calculate in the new table. 您可以在第一个表中添加新列(E),然后在新表中查找值或在新表中计算。

      E = SUMIFS(D$3:D$30,A$3:A$30,A3,C$3:C$30,C3,D$3:D$30,D3) E1 = {=INDEX(A$3:E$30,MATCH(G3&H3&I3,A$3:A$30&C$3:C$30&D$3:D$30,0),5)} E2 = SUMIFS(D$3:D$30,A$3:A$30,G3,C$3:C$30,H3,D$3:D$30,I3) 

在此处输入图片说明

I ended up creating a calculation sheet to create a unique key for each flight by concatenating the fields I wanted to match and also eliminated the duplicates by searching for "VALID_PC" which searched for the highest rank of the person in the crew flying. 我最终创建了一个计算表,通过连接我想匹配的字段为每个航班创建唯一的键,并且还通过搜索“ VALID_PC”来消除重复项,VALID_PC搜索了机组飞行人员中最高的人员。 The formulas I used in columns K and L were: 我在K和L栏中使用的公式是:

=IF(IFERROR(MATCH(H3,VALID_PC,0),"0"),A3&RIGHT(C3,5)&D3&E3,0)

and

=IFERROR(IF(A2=0,0,IF(COUNTIF($K$2:K3,K3)>1,0,1)),0)

This allowed me to do a simple {=SUM} on whether column L had a 1 in it on the main page.. 这使我可以对主页的L列中是否有1做一个简单的{= SUM}。

Calculations Sheet 计算表

I do appreciate the help and effort you all put in to help me. 我非常感谢大家为我提供的帮助。

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

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