Excel公式到SUMIF日期属于特定月份 [英] Excel Formula to SUMIF date falls in particular month

查看:1524
本文介绍了Excel公式到SUMIF日期属于特定月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 日期金额

03-Jan-13 430.00
25-Jan-13 96.00
10-Jan-13 440.00
28-Feb-13 72.10
28-Feb-13 72.30

只有当月份位于一月月份时,我需要总计金额字段。



我尝试过的是

  = SUMIF(A2:A6,MONTH(A2: A6)= 1,B2:B6)

但是返回

  0 

我需要什么是,

 以下值相加,430.00 + 96.00 + 440.00 = 966.00 


解决方案

请改为:

  = SUM(IF(MONTH($ A $ 2:$ A $ 6)= 1,$ B $ 2:$ B $ 6,0))

这是一个数组公式,所以你需要输入控件 - Shift - 输入组合键。



这是公式如何工作。


  1. MONTH($ A $ 2:$ A $ 6)创建一个数字数组,日期在A2:A6,即
    {1,1,1,2,2}

  2. 然后比较 {1,1,1,2,2} = 1 产生数组 {TRUE,TRUE,TRUE,FALSE,FALSE} ,其中包含IF语句的条件。

  3. IF语句返回一个值数组,其中 {430,96,400 .. 其中月值等于1的总和范围的值和 .. 0,0} 其中月值不等于1.

  4. 然后将数组 {430,96,400,0,0} 相加得到您要查找的答案。 li>

这实质上等同于SUMIF和SUMIF函数的功能。但是,这些函数都不支持您在条件中包含的那种计算方式。



还可以完全删除IF。由于TRUE和FALSE也可以被视为1和0,这个公式 - = SUM((MONTH($ A $ 2:$ A $ 6)= 1)* $ B $ 2:$ B $ 6) / code> - 也可以使用。



抬头:这在Google Spreadsheets中无效


I have excel data in following format.

Date        Amount

03-Jan-13   430.00 
25-Jan-13   96.00 
10-Jan-13   440.00 
28-Feb-13   72.10 
28-Feb-13   72.30

I need to sum the amount field only if the month lies in Jan Month.

What i have tried is ,

=SUMIF(A2:A6,"MONTH(A2:A6)=1",B2:B6)

But it returns,

0

What i need is,

Following values to be summed, 430.00 + 96.00 + 440.00 = 966.00

解决方案

Try this instead:

  =SUM(IF(MONTH($A$2:$A$6)=1,$B$2:$B$6,0))

It's an array formula, so you will need to enter it with the Control-Shift-Enter key combination.

Here's how the formula works.

  1. MONTH($A$2:$A$6) creates an array of numeric values of the month for the dates in A2:A6, that is,
    {1, 1, 1, 2, 2}.
  2. Then the comparison {1, 1, 1, 2, 2}= 1 produces the array {TRUE, TRUE, TRUE, FALSE, FALSE}, which comprises the condition for the IF statement.
  3. The IF statement then returns an array of values, with {430, 96, 400.. for the values of the sum ranges where the month value equals 1 and ..0,0} where the month value does not equal 1.
  4. That array {430, 96, 400, 0, 0} is then summed to get the answer you are looking for.

This is essentially equivalent to what the SUMIF and SUMIFs functions do. However, neither of those functions support the kind of calculation you tried to include in the conditional.

It's also possible to drop the IF completely. Since TRUE and FALSE can also be treated as 1 and 0, this formula--=SUM((MONTH($A$2:$A$6)=1)*$B$2:$B$6)--also works.

Heads up: This does not work in Google Spreadsheets

这篇关于Excel公式到SUMIF日期属于特定月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆