简体   繁体   English

Excel | 在这种情况下查找总金额的公式

[英]Excel | Formula to find total amount in this situation

Assume that we are currently in the month March . 假设我们目前在3月 I have a table with all the months and a list of products. 我有一张桌子,上面列出了所有月份和产品清单。 Inside each column i have the number sales a product has made on that month, like so: 在每个列中,我都有该月产品销售的数量,例如: 在此处输入图片说明

Notice i have a cell containing "Total until current month". 请注意,我有一个包含“截至当前月份总计”的单元格。 I would require a formula to find out the total amount of sales of a specific product (product A for example) up until March (current month) as you can see with the manually typed 6, 1 in Jan and 5 in Feb. 我将需要一个公式来找出特定产品(例如产品A)到3月(当月)的总销售额,就像您手动输入6、1月1日和2月5日所看到的那样。

I would usually do this by finding the sum of cell C4 and D5. 我通常会通过查找单元格C4和D5的总和来完成此操作。 But this should be 1 dynamic formula that is updating as we progress onto next month. 但这应该是1个动态公式,随着我们进入下个月而不断更新。 So as an exammple, in April, it will find the sum of cell C4 - E5 (Jan - March) and update the value. 例如,在4月,它将找到单元格C4-E5的和(1月-3月)并更新该值。

Is this possible? 这可能吗?

Regards 问候

Put a helper row above the month names that has the month numbers 1-12. 在月份名称上方放置一个具有1-12月份月份的帮助行。

Then use SUMIFS(): 然后使用SUMIFS():

=SUMIF($C$2:$N$2,"<=" &MONTH(TODAY()),C4:N4) = SUMIF($ C $ 2:$ N $ 2,“ <=”&MONTH(TODAY()),C4:N4)

在此处输入图片说明

You could hide that row so it is not visible and not readily accessible. 您可以隐藏该行,使其不可见且不易访问。

In row 3 put month numbers. 在第3行中输入月份数字。 Now if in cell Q4 you have a month number that you want to relate to use: 现在,如果在单元格Q4中,您有一个要使用的月份号:

=SUMIF($C$3:$N$3,"<"&$Q$4,C5:N5)

for sum of A and drag down for other products. A的总和,向下拖动其他产品。

If you want to pick the product you want sum for and have it all in one cell, then assuming that in cell R4 you have your product name (eg "B") write 如果您要选择想要求和的产品并将其全部存储在一个单元格中,则假定在单元格R4中您具有产品名称(例如“ B”),请写

=SUM((C3:N3<Q4)*C5:N6*(B5:B6=R4))

and press ctrl+shift+enter. 并按Ctrl + Shift + Enter。

The simplest solution is to leave E4 through N4 empty. 最简单的解决方案是将E4N4留空。 Only put a value in E4 once March is complete and you have a value for March. 仅在三月完成后将值放入E4中 ,并且您具有三月的值。 This will allow a formula like: 这将允许使用以下公式:

=SUM(C4:N4)

for Product A 用于产品A

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

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