[英]In Excel, sum all values in one column in each row where another column is a specific value
I'm wondering if there is an easy way to do what I'm looking for. 我想知道是否有一种简单的方法来做我正在寻找的东西。 Basically, I have a balance sheet in Excel 2011 with a bunch of data. 基本上,我在Excel 2011中有一堆资产表和一堆数据。 One specific piece of information I always want visible is the amount that hasn't been reimbursed. 我一直希望看到的一条特定信息是尚未报销的金额。 In other words, I have a column for the amount paid and another for whether or not it has been reimbursed (Yes/No). 换句话说,我有一个支付金额的列,另一个是否已经报销(是/否)。 I want to sum all of the amounts paid where the reimbursed field is equal to 'No'. 我希望将报销字段等于“否”的所有已支付金额相加。
I recognize I can sum the entire column and filter out those that have been reimbursed, but I'd like it to display the full amount regardless of what filter is on (or if no filter is on). 我知道我可以对整个列进行求和并筛选出已经报销的那些,但我希望它能显示全部数量,无论过滤器是什么(或者没有打开过滤器)。
I wasn't able to find good keywords to describe this to Google, so I'm asking here. 我无法找到好的关键字来向Google描述这一点,所以我在这里问。 I would like to accomplish this in Excel, not in an external program or script. 我想在Excel中完成此操作,而不是在外部程序或脚本中。
If column A contains the amounts to be reimbursed, and column B contains the "yes/no" indicating whether the reimbursement has been made, then either of the following will work, though the first option is recommended: 如果列A包含要报销的金额,并且列B包含“是/否”,表示是否已进行报销,则以下任一方法都可以,但建议使用第一个选项:
=SUMIF(B:B,"No",A:A)
or 要么
=SUMIFS(A:A,B:B,"No")
Here is an example that will display the amounts paid and outstanding for a small set of sample data. 这是一个示例,它将显示一小组样本数据的已支付金额和未付金额。
A B C D
Amount Reimbursed? Total Paid: =SUMIF(B:B,"Yes",A:A)
$100 Yes Total Outstanding: =SUMIF(B:B,"No",A:A)
$200 No
$300 No
$400 Yes
$500 No
You could do this using SUMIF
. 您可以使用SUMIF
执行此操作。 This allows you to SUM a value in a cell IF a value in another cell meets the specified criteria. 这允许您对单元格中的值进行求和,以使另一个单元格中的值满足指定的条件。 Here's an example: 这是一个例子:
- A B
1 100 YES
2 100 YES
3 100 NO
Using the formula: =SUMIF(B1:B3, "YES", A1:A3)
, you will get the result of 200
. 使用公式: =SUMIF(B1:B3, "YES", A1:A3)
,您将得到200
的结果。
Here's a screenshot of a working example I just did in Excel: 这是我在Excel中执行的一个工作示例的屏幕截图:
You should be able to use the IF function for that. 你应该可以使用IF函数。 the syntax is =IF(condition, value_if_true, value_if_false)
. 语法是=IF(condition, value_if_true, value_if_false)
。 To add an extra column with only the non-reimbursed amounts, you would use something like: 要添加仅包含非报销金额的额外列,您可以使用以下内容:
=IF(B1="No", A1, 0)
and sum that. 并总结一下。 There's probably a way to include it in a single cell below the column as well, but off the top of my head I can't think of anything simple. 可能有一种方法可以将它包含在列下方的单个单元格中,但是在我的脑海中,我无法想到任何简单的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.