简体   繁体   English

如何组合 SUMIF 的 Excel 公式并在文本字符串中查找数字?

[英]How do I combine the Excel formulas for a SUMIF and find number in text string?

I have a table in excel which has the date as column header and the rows have Project name, Area, and Resources (example below).我在 excel 中有一个表格,它的列标题是日期,行有项目名称、区域和资源(下面的示例)。 表格示例

As you can see in the example, there are a number of different resources listed for Project 1 in column 01/06/2020.正如您在示例中看到的,在 01/06/2020 列中为项目 1 列出了许多不同的资源。 Normally to add up all resources on a particular date I would use the formula通常要将特定日期的所有资源相加,我会使用公式

=SUMIF(tblPrgmm[Programme],"Resource",tblPrgmm[01/06/2020])

but for extracting the number of Pn's from the string I would use the formula但是为了从字符串中提取 Pn 的数量,我会使用公式

=MID(G21,FIND("pn",LOWER(G21),1)-1,1)

I need to somehow combine the two formulas so that it locates all the resource cells for that date, then extracts the relevant number from the text string.我需要以某种方式组合这两个公式,以便它找到该日期的所有资源单元格,然后从文本字符串中提取相关数字。

I have tried我试过了

=SUMPRODUCT((tblPrgmm[Programme]="Resource"),(MID(tblPrgmm[01/06/2020],FIND("pn",LOWER(tblPrgmm[01/06/2020]),1)-1,1)))

and

=SUMIF(tblPrgmm[Programme],"Resource",MID(G21,FIND("pn",LOWER(G21),1)-1,1))

but I cannot get this to work.但我无法让它发挥作用。 Please help.请帮忙。

You just need to find a project before searching for 'Resource'.您只需要在搜索“资源”之前找到一个项目。 You may use the following formula:您可以使用以下公式:

{=MID(INDEX(Table1[#All],MATCH(G1,Table1[Programme],0)+3,MATCH(TEXT(G2, "dd.MM.yyyy"),Table1[#Headers],0)),FIND("pn",LOWER(INDEX(Table1[#All],MATCH(G1,Table1[Programme],0)+3,MATCH(TEXT(G2, "dd.MM.yyyy"),Table1[#Headers],0))),1)-1,1)}

在此处输入图片说明

Format date in formula as you need.根据需要在公式中格式化日期。

Edit编辑

OK, here will be an option with the summing of all project resources on a single date:好的,这里有一个选项,可以在单个日期汇总所有项目资源:

{=SUM(IF((G1=Table1[Programme])*(TEXT(G2,"dd.MM.yyyy")=Table1[#Headers]),VALUE(MID(Table1,SEARCH(G3,Table1,1)-1,1)),0))}

在此处输入图片说明

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

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