SUMIF (VLOOKUP?) Based on days into weeks?

agerrard

Active Member
Joined
Apr 4, 2005
Messages
406
Hi All,

I have Excel 2007.

I have a data table that has sales by days (for lots and lots of products, but i've just used a very small sample here).

But i need to sum the daily sales data into weeks. Just not sure how i tell excel how to do that.

Starting in the Table tab and in cell D5 I need to find the product 1012BP10 in the Data tab and then i need to SUM all the sales for that product for the days that make up the week in cell D4 (in the Table tab) and then i need to do the same for the next week and so on...


Excel 2007
CDEFG
31012BP10
4Week Commencing27/04/20154/05/201511/05/201518/05/2015
5Quantity
Table
Cell Formulas
RangeFormula
E4=D4+7
F4=E4+7
G4=F4+7



Excel 2007
ABC
1StockCodeInvoiceDayQtyInPCS
21012BP1005-May-15120
31012BP1001-May-15120
41012BP1002-May-15120
51012BP1004-May-15120
61012BP1006-May-15120
7DH14715-May-15120
8DH14711-May-15120
91012BP1022-May-15120
101012BP1001-May-15120
11DH14721-May-15240
121012BP1004-May-15240
131012BP1004-May-15240
14CDT4PK05-May-15120
151012BP1004-May-15120
16CDT4PK26-May-15120
17CDT4PK04-May-15120
181012BP1021-May-15120
191012BP1026-May-15240
20CDT4PK04-May-15120
211012BP1015-May-15120
22CDT4PK01-May-15240
231012BP1022-May-15120
Data


Hopefully this makes sense?

Oh and i need to VLOOKUP in the Data tab as i need to sum multiple products (i just used a small sample here).

Cheers!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Based on your example data, try the following formula in cell D5 of your table tab, and copy across to the other weeks:

=SUMIFS(Data!$C$2:$C$23,Data!$A$2:$A$23,$C$1,Data!$B$2:$B$23,">="&D$4,Data!$B$2:$B$23,"<="&D$4+6)

Adjust the cell ranges in the formula to suit your data sheet as necessary.


Chris
 
Upvote 0
You may try this:

on D5:
Code:
=SUMPRODUCT(--(Data[QtyInPCS])*(Data[StockCode]=$C$3)*(Data[InvoiceDay]>=D4)*(Data[InvoiceDay]<=(D4+6)))

For this to work you need to format your data as a table, the advantage of this is that you will never need to worry about adjusting ranges, no matter how much data you add to or remove from your DATA tab. To avoid unwanted changes on format first declare a new table style without declaring any format.

If you don't like to use tables just use a substitute each table call with the corresponding range (i.e Data[QtyInPCS] will become DATA!$A2:$A$? (? means the last row number) but remember, you will have to adjust your range every time you add or delete data from your DATA tab.

Hope this helps.
Saludos Amigo.
 
Upvote 0
Based on your example data, try the following formula in cell D5 of your table tab, and copy across to the other weeks:

=SUMIFS(Data!$C$2:$C$23,Data!$A$2:$A$23,$C$1,Data!$B$2:$B$23,">="&D$4,Data!$B$2:$B$23,"<="&D$4+6)

Adjust the cell ranges in the formula to suit your data sheet as necessary.


Chris


Thanks for you reply cdchapman. I copied the formula but what i noticed was that there is no provision to in the formula to search by the product code (eg. the value in cell C3 in the Table tab).

What im hoping to do is (starting in cell D5 in the Table tab):

1. Look at the value in C3
2. Then go find the sales for that product (column A) in the Data tab (as in SUM the sales) for the DAYS (e.g. in column B) that make up the WEEK in cell D4 etc...

Would it be a VLOOKUP and SUMIF combination?

Thanks
 
Upvote 0
Hi Chris,

Thanks again for you help. I didnt read the formula correctly the first time, but now its working great! Have a good weekend!
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,175
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top