简体   繁体   中英

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.

I want it to be able to pull the current month of the year and compare YTD sales in the C column from that.

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.

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:

=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.

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. It will automatically set the last row with a number in column A as the last row of the dataset.

So as the dataset grows or shrinks we will not be doing any unneeded iterations.

Change {2004,2005} to any number of years desired.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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