Filter rows by date (A column) and write sum (C column) to field in another sheet

非 Y 不嫁゛ 提交于 2019-12-07 19:09:08

问题


I have two sheets in Google Spreadsheet document. The first one has columns Month, Income, Expense and Profit (A,B,C,D respectively) and in each row expense value should be calculated based from filter (I think) from another sheet called Expenses.

The Expenses sheet contains columns Date, Name and Price.

So, what I need is to write formula to filter only expenses for specific month, to sum all prices in those rows and to write that value to C column (row for that month) in first sheet.

You can see this example and please help me out to solve this.


回答1:


This is a formula that can be filled down (I have entered it in F2):

=ArrayFormula(SUMIF(TEXT(Expenses!A$2:A;"MMMM");A2;Expenses!C$2:C))

This is a formula that will automatically populate results down the column (I have entered it in G2):

=ArrayFormula(IF(LEN(A2:A);SUMIF(TEXT(Expenses!A2:A;"MMMM");A2:A;Expenses!C2:C);IFERROR(1/0)))

And this formula will take the year into consideration; I have entered it in J2, referencing month-year strings in I2:I:

=ArrayFormula(IF(LEN(I2:I);SUMIF(TEXT(Expenses!A2:A;"MMMM yyyy");I2:I;Expenses!C2:C);IFERROR(1/0)))



来源:https://stackoverflow.com/questions/13439346/filter-rows-by-date-a-column-and-write-sum-c-column-to-field-in-another-shee

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!