简体   繁体   English

Excel:跨工作簿数据挖掘

[英]Excel: Cross-workbook data mining

At work, we track our payments collected in an effort to reach a daily goal. 在工作中,我们会跟踪为实现每日目标而收取的款项。 As such, our payments are tracked in our individual Excel workbooks. 因此,我们的付款会在我们各自的Excel工作簿中进行跟踪。 An example of said workbook is below: 所述工作簿的示例如下:

Google Docs Payment Log (modified) Google文件付款记录(已修改)

We use Excel 2013 at work. 我们在工作中使用Excel 2013。 I have a "Tracker Log" that is a separate workbook. 我有一个“跟踪器日志”,它是一个单独的工作簿。 Originally I had it tracking inside the existing workbook, but moved it to the outside workbook for ease of copy/paste for our team lead. 最初,我在现有工作簿中进行跟踪,但是为了便于团队领导进行复制/粘贴,将其移至外部工作簿中。

In the Tracker Log, I have the current workable days in Column A (dates occurring Monday through Friday for the month of August). 在“跟踪器日志”中,我在A列中拥有当前可行的日期(日期发生在8月的星期一至星期五)。 Each day is supposed to list how many payments were collected and the sum of the payments. 每天应该列出收集的付款数量以及付款总和。 That part, I figured out from research and had the following formula with the Payment Log: 我从研究中发现了这一部分,并在付款日志中具有以下公式:

=IF(NOT(ISBLANK(A2)), COUNT(B2:INDEX(B2:$B$500,MATCH(TRUE,INDEX(B2:$B$500="",0),0))),"")

and a similar one for SUM. 和SUM相似的。 It worked great for its purpose, and I was pleased when it was in the Payment Log. 它可以很好地达到目的,当我将它放在“付款日志”中时,我感到很高兴。 Moving it to the Tracker Log, however, did not produce intended results. 但是,将其移至“跟踪器日志”并不会产生预期的结果。 The formula works; 该公式有效; it's not broken. 它没有坏。 The undesired result, however, is that instead of each line producing the day's information, the formula causes it to skip down to the corresponding row in the Payment Log. 但是,不希望出现的结果是,该公式导致它跳到了付款日志中的相应行,而不是每行都显示当天的信息。 That is, instead of Row 2 being 8/1 and Row 3 being 8/2's information, Row 1 is 8/1 and the row that 8/2 falls on in the Payment Log is the row the Tracker log populates. 也就是说,第2行不是8/1,第3行是8/2的信息,第1行是8/1,支付日志中8/2位于的行是Tracker日志填充的行。 (View Sheet2 to see the undesired behavior.) (查看Sheet2以查看不良行为。)

What formula do I need to use for the desired behavior? 我需要为期望的行为使用什么公式?

EDIT 编辑

After sneakily taking home the information (and modifying so no account information is released), I've found the selected answer does not work at all. 偷偷带回家的信息(并进行修改,以便不发布任何帐户信息)后,我发现所选答案根本不起作用。 See the (modified) Google Spreadsheet above to show what is happening. 请参阅上面的(已修改)Google Spreadsheet,以显示正在发生的事情。

For me to make it work, I need in B2: 为了使它起作用,我需要在B2中:

=IFERROR(COUNTIF(INDEX(Sheet1!B:B,MATCH(A2,Sheet1!A:A,0)):INDEX(Sheet1!B:B,MATCH(TRUE,INDEX(Sheet1!B:B,MATCH(A2,Sheet1!A:A,0)):INDEX(Sheet1!B:B,MATCH(A2,Sheet1!A:A,0)+100)=0,0)),"<>"),"")

and in C2: 在C2中:

=IFERROR(SUM(INDEX(Sheet1!C:C,MATCH(A2,Sheet1!A:A,0)):INDEX(Sheet1!C:C,MATCH(TRUE,INDEX(Sheet1!B:B,MATCH(A2,Sheet1!A:A,0)):INDEX(Sheet1!B:B,MATCH(A2,Sheet1!A:A,0)+100)=0,0))),"")

And then copy down B2:C2. 然后复制下来B2:C2。

This are array formulas and must be confirmed with ctrl + shift + enter . 这是数组公式,必须使用ctrl + shift + enter进行确认。

EDIT there was just a small error in it :P 编辑中只有一个小错误:P

For B2: 对于B2:

=IFERROR(COUNTIF(INDEX('Sept 2016'!B:B,MATCH(A2,'Sept 2016'!A:A,0)):INDEX('Sept 2016'!B:B,MATCH(TRUE,INDEX('Sept 2016'!B:B,MATCH(A2,'Sept 2016'!A:A,0)):INDEX('Sept 2016'!B:B,MATCH(A2,'Sept 2016'!A:A,0)+100)=0,0)+MATCH(A2,'Sept 2016'!A:A,0)-2),"<>"),"")

and for C2: 对于C2:

=IFERROR(SUM(INDEX('Sept 2016'!C:C,MATCH(A2,'Sept 2016'!A:A,0)):INDEX('Sept 2016'!C:C,MATCH(TRUE,INDEX('Sept 2016'!B:B,MATCH(A2,'Sept 2016'!A:A,0)):INDEX('Sept 2016'!B:B,MATCH(A2,'Sept 2016'!A:A,0)+100)=0,0)+MATCH(A2,'Sept 2016'!A:A,0)-2)),"")

This are array formulas and must be confirmed with ctrl + shift + enter . 这是数组公式,必须使用ctrl + shift + enter进行确认。

I missed the part to offset outcome of MATCH(TRUE,...,0) so the upper index will not count from row 1. Sorry for this. 我错过了抵消MATCH(TRUE,...,0)结果的部分MATCH(TRUE,...,0)因此高索引不会从第1行开始计数。对此很抱歉。

The formulas from B2 and C2 can be copied down. B2和C2中的公式可以向下复制。 Also used your sheet naming. 还使用了工作表命名。 ;) ;)

EDIT 2 编辑2

Theoretical COUNTIF cannot return TRUE . 理论上的COUNTIF无法返回TRUE I suggest some different error which simply will not pop up on my excel (also google sheets). 我建议一些不同的错误,这些错误根本不会在我的Excel中弹出(也是Google工作表)。 Please try this formula for B2: 请为B2尝试以下公式:

=IFERROR(SUM((INDEX('Sept 2016'!B:B,MATCH(A2,'Sept 2016'!A:A,0)):INDEX('Sept 2016'!B:B,MATCH(TRUE,INDEX('Sept 2016'!B:B,MATCH(A2,'Sept 2016'!A:A,0)):INDEX('Sept 2016'!B:B,MATCH(A2,'Sept 2016'!A:A,0)+100)=0,0)+MATCH(A2,'Sept 2016'!A:A,0)-2)<>"")*1),"")

This is an array formula and must be confirmed with ctrl + shift + enter . 这是一个数组公式,必须使用ctrl + shift + enter进行确认。

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

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