简体   繁体   English

获取单元格中以分号分隔的最大字符串

[英]Get maximum string of semicolon-separated values in a cell

I am trying to sum all the values that belong to a squads that have been completed in a sprint.我正在尝试总结属于在冲刺中完成的小队的所有值。 I have source table that contains 3 columns (Squad Name, Value, Sprint).我有包含 3 列(小队名称、值、Sprint)的源表。 The Sprint column has cells that contain semicolon-separated lists. Sprint 列的单元格包含以分号分隔的列表。

源数据

What I am trying to achieve is sum all values in Column B where the criteria are:我想要实现的是汇总 B 列中的所有值,其中标准是:

  1. Squad name = Tigers小队名称 = Tigers
  2. MAX Sprint = Sprint 11最大冲刺 = 冲刺 11

I would like to sum those values in Column B where the max sprint value in Column C is Sprint 11. I would not like to include those values where the max value in Column C is sprint 12.我想将 B 列中的那些值相加,其中 C 列中的最大 sprint 值为 Sprint 11。我不想包括 C 列中的最大值为 sprint 12 的那些值。

At the moment I have got: =SUMIFS(B2:12,A2:12,"Tigers",C2:C12,...)目前我得到了:=SUMIFS(B2:12,A2:12,"Tigers",C2:C12,...)

Can someone help me figure out the last bit?有人可以帮我弄清楚最后一点吗? Thanks谢谢

If you want to sum only Sprint 11 having squad name tigers then try-如果您只想总结具有小队名称 Tigers 的 Sprint 11,请尝试-

=QUERY(ArrayFormula(SPLIT(FLATTEN(SPLIT(FILTER(C2:C8,A2:A8="Tigers"),";"))," ")),"select sum(Col2) where Col2=11 label sum(Col2) ''")

在此处输入图像描述

use:利用:

=SUMPRODUCT(QUERY(SPLIT(FLATTEN(B1:B&"×"&TRIM(SPLIT(C1:C, ";"))), "×"), 
 "select Col1 where Col2 = 'Sprint 11'"))

在此处输入图像描述

If you always expect to have exactly three sprints formatted as shown, you can use the following query to get the sum of all rows where the Squad Name is "Tigers" and the highest Sprint value in that row is exactly 11.如果您总是希望恰好三个 Sprint 的格式如图所示,您可以使用以下查询来获取 Squad Name 为“Tigers”且该行中最高 Sprint 值恰好为 11 的所有行的总和。

=QUERY({A2:A,B2:B,ARRAYFORMULA(INT(SPLIT(REGEXREPLACE(C2:C,"[a-zA-Z ]",""),";")))},"select sum(Col2) where Col1='Tigers' and (Col3>=11 or Col4>=11 or Col5>=11) and not (Col3>=12 or Col4>=12 or Col5>=12) label sum(Col2) ''")

If you expect that the number of sprints might change (for example, a cell in column C with the value "Sprint 2;Sprint 3;Sprint 11;Sprint 12") then this formula will work instead.如果您预计 sprint 的数量可能会发生变化(例如,C 列中的一个单元格的值是“Sprint 2;Sprint 3;Sprint 11;Sprint 12”),那么这个公式将起作用。

=QUERY({FILTER(A2:A,NOT(ISBLANK(C2:C))),FILTER(B2:B,NOT(ISBLANK(C2:C))),QUERY(TRANSPOSE(QUERY(TRANSPOSE(ARRAYFORMULA(IF(ISBLANK(C2:C),,INT(SPLIT(REGEXREPLACE(C2:C,"[a-zA-Z ]",""),";"))))),"select "&REGEXREPLACE(JOIN("",ARRAYFORMULA(IF(LEN(C2:C),"max(Col"&ROW(C2:C)-ROW(C2)+1&"), ",""))),"..\z",""))),"select Col2")},"select sum(Col2) where Col1='Tigers' and Col3=11 label sum(Col2) ''")

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

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