SUM multiple cells data IF month matches date column

joshua0

New Member
Joined
Oct 9, 2018
Messages
3
Hi,

I'm having some trouble working out how to return the sum value of an item for any given month.

Each column represents an order and each row a product. The data shows the qty of that product ordered on that date:

01/01/201905/01/201904/02/201921/02/201926/02/201904/03/2019
Item 1036246
Item 2214021
Item 3146122
Item 4440244
Item 5421311
Item 6033202

<colgroup><col><col><col span="5"></colgroup><tbody>
</tbody>


I need to map this to show the qty of each item ordered per month.


JanFebMarch
Item 13126
Item 2361
Item 3572
Item 4824
Item 5641
Item 6352

<colgroup><col><col><col span="5"></colgroup><tbody>
</tbody>


First off, I know I can use pivot tables, but that doesn't really fit in to the rest of what I'm trying to do. In this instance, I need to use regular formulas.

I've been trying to use INDEX MATCH MATCH, but that only wants to return the value of a single cell, not the sum of multiple cells meeting the criteria.

I've also used =SUM(IF(MONTH($B$1:$G$1)=MONTH(B$10),$B$2:$G$7)) to sum all the values in the date range, but I can't figure out how to limit that to a single row/product? I was thinking HLOOKUP, but using a numeric value rather than a dynamic lookupto pick the row is a bit of a limitation.

Anyone have any ideas?

Thanks

Josh
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi & welcome to MrExcel.

How about


Excel 2013/2016
ABCDEFGHIJKLMNOP
101/01/201905/01/201904/02/201921/02/201926/02/201904/03/2019JanFebMar
2Item 1036246Item 13126
3Item 2214021Item 2361
4Item 3146122Item 3592
5Item 4440244Item 4864
6Item 5421311Item 5651
7Item 6033202Item 6352
Index
Cell Formulas
RangeFormula
N2=SUMPRODUCT((TEXT($B$1:$G$1,"mmm")=N$1)*($A$2:$A$7=$M2),$B$2:$G$7)
O2=SUMPRODUCT((TEXT($B$1:$G$1,"mmm")=O$1)*($A$2:$A$7=$M2),$B$2:$G$7)
P2=SUMPRODUCT((TEXT($B$1:$G$1,"mmm")=P$1)*($A$2:$A$7=$M2),$B$2:$G$7)


Your output headers will all need to be 3 letter format
 
Upvote 0
you can try PowerQuery

item01/01/201905/01/201904/02/201921/02/201926/02/201904/03/2019itemJanuaryFebruaryMarch
Item 1
0​
3​
6​
2​
4​
6​
Item 1
3​
12​
6​
Item 2
2​
1​
4​
0​
2​
1​
Item 2
3​
6​
1​
Item 3
1​
4​
6​
1​
2​
2​
Item 3
5​
9​
2​
Item 4
4​
4​
0​
2​
4​
4​
Item 4
8​
6​
4​
Item 5
4​
2​
1​
3​
1​
1​
Item 5
6​
5​
1​
Item 6
0​
3​
3​
2​
0​
2​
Item 6
3​
5​
2​
Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"item", type text}, {"01/01/2019", Int64.Type}, {"05/01/2019", Int64.Type}, {"04/02/2019", Int64.Type}, {"21/02/2019", Int64.Type}, {"26/02/2019", Int64.Type}, {"04/03/2019", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"item"}, "Attribute", "Value"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Attribute", type date}}),
    #"Extracted Month Name" = Table.TransformColumns(#"Changed Type1", {{"Attribute", each Date.MonthName(_), type text}}),
    #"Pivoted Column" = Table.Pivot(#"Extracted Month Name", List.Distinct(#"Extracted Month Name"[Attribute]), "Attribute", "Value", List.Sum)
in
    #"Pivoted Column"[/SIZE]
 
Last edited:
Upvote 0
Thanks Fluff, that's perfect!

I put in the months (Jan, Feb, March) as dates (01/01/19, 01/02/19, 01/03/19) then custom formatted the cells as 'mmm' so they show as Jan, Feb, March.

=SUMPRODUCT((MONTH($B$1:$G$1,"mmm")=MONTH(N$1))*($A$2:$A$7=$M2),$B$2:$G$7)
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0
Thanks Fluff, that's perfect!

I put in the months (Jan, Feb, March) as dates (01/01/19, 01/02/19, 01/03/19) then custom formatted the cells as 'mmm' so they show as Jan, Feb, March.

=SUMPRODUCT((MONTH($B$1:$G$1,"mmm")=MONTH(N$1))*($A$2:$A$7=$M2),$B$2:$G$7)

Hi,

Actually I think you have a syntax error (too many arguments) for your formula as posted above.
Also, if N1:P1 are actual dates, you don't need "mmm" within your formula (which is causing the error), so just this will do:


Book1
ABCDEFGHIJKLMNOP
11/1/20191/5/20192/4/20192/21/20192/26/20193/4/2019JanFebMar
2Item 1036246Item 13126
3Item 2214021Item 2361
4Item 3146122Item 3592
5Item 4440244Item 4864
6Item 5421311Item 5651
7Item 6033202Item 6352
Sheet319
Cell Formulas
RangeFormula
N2=SUMPRODUCT((MONTH($B$1:$G$1)=MONTH(N$1))*($A$2:$A$7=$M2)*$B$2:$G$7)
 
Upvote 0

Forum statistics

Threads
1,214,391
Messages
6,119,244
Members
448,879
Latest member
VanGirl

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