根据多个条件和查找表对一组值求和

发布于 2025-01-13 22:03:01 字数 2482 浏览 4 评论 0原文

我得到了以下销售表,其中提供了每个员工的销售额,但我没有他们的名字,而是他们的 ID,并且每个 ID 可能有超过 1 行。

为了将 ID 映射回姓名,我有一个包含每个员工的姓名和 ID 的查找表。需要记住的一件事是,任何给定名称都可能分配有多个 ID,如下例所示:

Sales 表:

年份IDNorthSouthWestEast
2020A58307472
2020A85409079
2020B982205
2020B77134921
2020C85553711
2020C29702122
2021A61372142
2021A2239234
2021B6255972
2021B5911237
2021C41226447
2021C83185683

ID 表:

ID姓名
AAllison
BBrandon
CBrandon

我正在尝试按给定年份汇总每个员工的销售额,并按他们的姓名(而不是 ID)汇总他们的所有交易,以便我的结果看起来如下所示:

结果:

Report
2021
Allison258
Brandon721

我希望用户能够选择年份,并且报告会自动总结每个人的销售额年份和他们的名字。同样,Brandon 被分配了 ID B 和 C,因此报告应该能够获取 B 和 C 下的所有 2021 年销售额。

我发布了类似的 问题,其中不包括将名称与多个 ID 绑定所增加的复杂性。在该线程中,我得到了一个包含以下公式的解决方案:

=SUMPRODUCT($C$2:$F$13*($B$2:$B$13=INDEX($I$2:$I$4,MATCH(N3,$J$2:$J$4,0)))*($A$2:$A$13=$N$2))

虽然此公式适用于仅与一个 ID 相关联的名称,但我相信 INDEX 和 MATCH 组件一旦在 ID 表上遇到重复名称,就会失败。

我目前使用的是 Excel 2016,因此任何解决方案都需要至少与该版本兼容。预先感谢您对此的任何指导。

I am given the following sales table which provide the sales that each employee made, but instead of their name I have their ID and each ID may have more than 1 row.

To map the ID back to the name, I have a look up table with each employee's name and ID. One thing to keep in mind is that any given name could potentially have more than one ID assigned to it, as described in the example below:

Sales Table:

YearIDNorthSouthWestEast
2020A58307472
2020A85409079
2020B982205
2020B77134921
2020C85553711
2020C29702122
2021A61372142
2021A2239234
2021B6255972
2021B5911237
2021C41226447
2021C83185683

ID table:

IDName
AAllison
BBrandon
CBrandon

I am trying to sum up each employee's sales by a given year, and aggregate all their transactions by their name (rather than ID), so that my result looks like the following:

Result:

Report
2021
Allison258
Brandon721

I want the user to be able to select the year, and the report would automatically sum up each person's sales by the year and their name. Again, Brandon was assigned ID B and C, so the report should be able to obtain all 2021 sales under B and C.

I posted a similar question which did not include the added complexity of having a name tied to more than one ID. In that thread, I was provided a solution with the following formula:

=SUMPRODUCT($C$2:$F$13*($B$2:$B$13=INDEX($I$2:$I$4,MATCH(N3,$J$2:$J$4,0)))*($A$2:$A$13=$N$2))

While this formula works on names that only have one ID tied to it, I believe the INDEX and MATCH component falls through once it encounters a duplicate name on the ID table.

I am currently using Excel 2016, so any solution would need to be compatible with that version at least. Thanks in advance for any guidance on this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖微凉心微凉 2025-01-20 22:03:01

尝试这个公式解决方案可以在您的 Excel 2016

中使用L4,复制下来的公式:

=SUMPRODUCT(($A$3:$A$14=K$3)*(VLOOKUP(T(IF({1},$B$3:$B$14)),$H$3:$I$5,2,0)=K4)*$C$3:$F$14)

在此处输入图像描述

Try this formula solution can work in your Excel 2016

In L4, formula copied down :

=SUMPRODUCT(($A$3:$A$14=K$3)*(VLOOKUP(T(IF({1},$B$3:$B$14)),$H$3:$I$5,2,0)=K4)*$C$3:$F$14)

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文