简体   繁体   English

索引匹配跨多列匹配

[英]Index Match Match across multiple columns

I have an Index Match Match question that I have not been able to find the answer for in researching. 我有一个索引匹配问题,我无法在研究中找到答案。 Although the solution may actually might be different than an Index Match Match formula - I'm open to try something more efficient than my current workaround. 虽然解决方案实际上可能与索引匹配匹配公式不同 - 我可以尝试比我当前的解决方法更有效的方法。

I have one worksheet with data from my company on it. 我有一个工作表,上面有我公司的数据。 We sell a Product (let's call it Coke Zero) and we track the weeks that we put a promotion on and how much profit we make by selling it to the retailer. 我们销售一种产品(我们称之为Coke Zero),我们跟踪我们推销的周数以及通过将其出售给零售商而获得的利润。 For example a promotion for Coke Zero starts the first week of Jan and ends 3 weeks later and we make a gross profit of $100 each week the promotion runs. 例如,可口可乐零的促销活动从1月的第一周开始,到3周后结束,我们每周促销活动的毛利润为100美元。 I then have an external database with sales data formatted on a weekly basis to tell me how many units of Coke Zero I sold in each week. 然后我有一个外部数据库,每周都会格式化销售数据,告诉我每周销售的Coke Zero有多少单位。 My internal data has thousands of lines like this with dozens of products, however the promotions are consolidated on one single row regardless of if it runs for more than one week, making matching up to the external database difficult. 我的内部数据有数千条这样的产品线,有数十种产品,但是促销在一行中合并,无论它是否运行超过一周,都难以与外部数据库匹配。 I need to create a lookup for what our Gross Profit was for each week of the promotion. 我需要创建一个查找我们的促销每周的毛利润。

I have attached an example image of the workbook + two data sheets of what I've tried to do, summarised below. 我附上了工作簿的示例图像+我试图做的两个数据表,总结如下。 On the Internal Data Sheet I've created additional columns to the right with all of the weeks listed that the promotion is on for, and concatenated them with the Product Code to be able to match week by week to the data in the External data sheet. 在内部数据表中,我创建了右侧的其他列,列出了促销所在的所有周,并将它们与产品代码连接起来,以便能够逐周匹配外部数据表中的数据。 Then my lookup basically checks every column one after another until it finds one where the concatenate of Week_Product Code concatenate matches. 然后我的查找基本上一个接一个地检查每一列,直到它找到一个Week_Product代码连接的连接匹配的列。

示例Screengrab来自Excel工作簿

My current solution technically works but my final formula is really slow and cumbersome given the data can be anywhere from 10K-200K lines when looking at multiple retailers. 我目前的解决方案在技术上有效,但我的最终公式非常缓慢而且繁琐,因为在查看多个零售商时,数据可能是10K-200K线。 I was hoping to find a more efficient formula to complete the lookup. 我希望找到一个更有效的公式来完成查找。

Current solution on the External Data Sheet Column E: 外部数据表E列的当前解决方案:

=IF(ISNUMBER(MATCH(D2,'Internal Data'!$E:$E,0)),INDEX('Internal Data'!$D:$D,MATCH(D2,'Internal Data'!$E:$E,0)),
IF(ISNUMBER(MATCH(D2,'Internal Data'!$F:$F,0)),INDEX('Internal Data'!$D:$D,MATCH(D2,'Internal Data'!$F:$F,0)),
IF(ISNUMBER(MATCH(D2,'Internal Data'!$G:$G,0)),INDEX('Internal Data'!$D:$D,MATCH(D2,'Internal Data'!$G:$G,0)),
"0")))

I got SUMPRODUCT to work using this formula in J2 : 我在J2使用这个公式得到了SUMPRODUCT

=SUMPRODUCT(--($B$2:$D$3=H2)*--($E$2:$E$3=I2)*$F$2:$F$3)

And , you don't need those concatenated lookup columns: 而且 ,您不需要这些连接的查找列:

在此输入图像描述

Well, that was fun. 嗯,这很有趣。

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

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