[英]Using SUMIFS to pull YTD sales data in excel
I am looking for a way to pull out YTD data for a spreadsheet that has the following in the A,B,C Columns. 我正在寻找一种为A,B,C列中包含以下内容的电子表格提取YTD数据的方法。
I want it to be able to pull the current month of the year and compare YTD sales in the C column from that. 我希望它能够拉出当年的当前月份并从中比较C列中的YTD销售额。
I have used =SUM(IF(YEAR(A:A)=2016,C:C,0)) to get the entire year data but want just jan - current month for each year listed. 我已经使用= SUM(IF(YEAR(A:A)= 2016,C:C,0))来获取整年的数据,但只想要jan-列出的每一年的当前月份。
YTD Sales Through May 2008
2009
2010
2011
2012
2013
2014
2015
2016
Jan-03 17 $86,625
Feb-03 17 $107,900
Mar-03 21 $103,400
Apr-03 17 $112,050
May-03 20 $75,145
Jun-03 26 $198,800
Jul-03 14 $80,695
Aug-03 19 $50,940
Sep-03 26 $152,380
Oct-03 23 $109,380
Nov-03 19 $113,875
Dec-03 21 $149,275
Jan-04 30 $113,110
Feb-04 17 $109,493
Mar-04 15 $69,690
Apr-04 25 $123,145
May-04 24 $136,685
Jun-04 30 $148,495
Jul-04 21 $138,990
Aug-04 29 $131,005
Sep-04 38 $165,790
Oct-04 43 $173,190
Nov-04 41 $253,915
Dec-04 39 $217,650
You would use this formula and change the Year to what you want: 您将使用此公式并将Year更改为所需的值:
=SUMPRODUCT((MONTH($A$1:$A$24)<=MONTH(TODAY()))*(YEAR($A$1:$A$24)=2016)*$C$1:$C$24)
If you want all the years YTD in one formula you can: 如果您想用一个公式得出年初至今的所有年份,则可以:
=SUMPRODUCT((MONTH($A$1:$A$24)<=MONTH(TODAY()))*(YEAR($A$1:$A$24)={2008,2009,2010,2011,2012,2013,2014,2015,2016})*$C$1:$C$24)
To make the formula more dynamic, so it grows and contracts with the size of the data use this; 为了使公式更加动态,使其随数据的大小增长和收缩,请使用此公式;
=SUMPRODUCT((MONTH($A$2:INDEX(A:A,MATCH(1E+99,A:A)))<=MONTH(TODAY()))*(YEAR($A$2:INDEX(A:A,MATCH(1E+99,A:A)))={2004,2005})*$C$2:INDEX(C:C,MATCH(1E+99,A:A)))
Make sure that the references $A$2
and $C$2
refer to the first cell of data and not the title row. 确保引用$A$2
和$C$2
引用数据的第一个单元格而不是标题行。
With Array formula's calculations being exponential we need to limit the reference to only the dataset size. 在数组公式的计算是指数的情况下,我们需要将引用限制为仅数据集大小。 All the INDEX(A:A,MATCH(1E+99,A:A))
accomplish this. 所有INDEX(A:A,MATCH(1E+99,A:A))
可以完成此操作。 It will automatically set the last row with a number in column A as the last row of the dataset. 它将自动用数字A设置最后一行,并将其设置为数据集的最后一行。
So as the dataset grows or shrinks we will not be doing any unneeded iterations. 因此,随着数据集的增长或收缩,我们将不会进行任何不必要的迭代。
Change {2004,2005}
to any number of years desired. 将{2004,2005}
更改为任意年份。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.