Lookup table array and sum all rows that are applicable

Nubie2019

New Member
Joined
Mar 6, 2019
Messages
9
Hello,

I want to sum all "Apples" under the "Jan" Column in the following table. I want to make the formula dynamic by having the formula lookup the entire table and select the correct columns and rows rather than using "Sumifs" on a per column basis. Any help will be appreciated.

The formula should add the items in RED.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]Jan[/TD]
[TD]Feb[/TD]
[TD]Mar[/TD]
[/TR]
[TR]
[TD]Apples[/TD]
[TD]1[/TD]
[TD]6[/TD]
[TD]11[/TD]
[/TR]
[TR]
[TD]Oranges[/TD]
[TD]6[/TD]
[TD]11[/TD]
[TD]16[/TD]
[/TR]
[TR]
[TD]Apples[/TD]
[TD]11[/TD]
[TD]16[/TD]
[TD]21[/TD]
[/TR]
[TR]
[TD]Lemons[/TD]
[TD]16[/TD]
[TD]21[/TD]
[TD]26[/TD]
[/TR]
</tbody>[/TABLE]
 

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
with PowerQuery unpivot columns
Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Fruits"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"[/SIZE]
then use PivotTable

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]Fruits[/td][td=bgcolor:#5B9BD5]Jan[/td][td=bgcolor:#5B9BD5]Feb[/td][td=bgcolor:#5B9BD5]Mar[/td][td][/td][td=bgcolor:#DDEBF7]Fruits[/td][td=bgcolor:#DDEBF7]Apples[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]Apples[/td][td=bgcolor:#DDEBF7]
1​
[/td][td=bgcolor:#DDEBF7]
6​
[/td][td=bgcolor:#DDEBF7]
11​
[/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]Oranges[/td][td]
6​
[/td][td]
11​
[/td][td]
16​
[/td][td][/td][td=bgcolor:#DDEBF7]Attribute[/td][td=bgcolor:#DDEBF7]Sum of Value[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]Apples[/td][td=bgcolor:#DDEBF7]
11​
[/td][td=bgcolor:#DDEBF7]
16​
[/td][td=bgcolor:#DDEBF7]
21​
[/td][td][/td][td]Jan[/td][td]
12​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]Lemons[/td][td]
16​
[/td][td]
21​
[/td][td]
26​
[/td][td][/td][td]Feb[/td][td]
22​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td][/td][td][/td][td][/td][td][/td][td][/td][td]Mar[/td][td]
32​
[/td][/tr]
[/table]
 
Upvote 0
Try this formula

Excel Workbook
ABCDEFGHI
1FRUITJanFebMarFruitMonthSum
2Apples1611ApplesJan=H2)*(Tabla1:]))]12
3Oranges61116
4Apples111621
5Lemons162126
Hoja24
 
Upvote 0
with PowerQuery unpivot columns
Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table4"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Fruits"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"[/SIZE]
then use PivotTable

[TABLE="class: head"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Fruits[/COLOR][/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Jan[/COLOR][/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Feb[/COLOR][/TD]
[TD="bgcolor: #5B9BD5"][COLOR=[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] ]Mar[/COLOR][/TD]
[TD][/TD]
[TD="bgcolor: #DDEBF7"]Fruits[/TD]
[TD="bgcolor: #DDEBF7"]Apples[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: #DDEBF7"]Apples[/TD]
[TD="bgcolor: #DDEBF7"]
1​
[/TD]
[TD="bgcolor: #DDEBF7"]
6​
[/TD]
[TD="bgcolor: #DDEBF7"]
11​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD]Oranges[/TD]
[TD]
6​
[/TD]
[TD]
11​
[/TD]
[TD]
16​
[/TD]
[TD][/TD]
[TD="bgcolor: #DDEBF7"]Attribute[/TD]
[TD="bgcolor: #DDEBF7"]Sum of Value[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD="bgcolor: #DDEBF7"]Apples[/TD]
[TD="bgcolor: #DDEBF7"]
11​
[/TD]
[TD="bgcolor: #DDEBF7"]
16​
[/TD]
[TD="bgcolor: #DDEBF7"]
21​
[/TD]
[TD][/TD]
[TD]Jan[/TD]
[TD]
12​
[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD]Lemons[/TD]
[TD]
16​
[/TD]
[TD]
21​
[/TD]
[TD]
26​
[/TD]
[TD][/TD]
[TD]Feb[/TD]
[TD]
22​
[/TD]
[/TR]
[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FFFFFF]#FFFFFF[/URL] "]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Mar[/TD]
[TD]
32​
[/TD]
[/TR]
</tbody>[/TABLE]


Thanks:) Was hoping for a formula solution. But will keep this in mind...thanks again!!
 
Upvote 0
Thanks! I tried this and get a
#VALUE ! Error. The formula I have is "=SUMPRODUCT(Table1[Fruit]=G2)*(Table1[[#Headers],[Jan]:[Mar]]=H2*(Table1[[Jan]:[Mar]])". Does it work for you?
 
Upvote 0
Thanks Dante! I tried this and get a
#VALUE ! Error. The formula I have is "=SUMPRODUCT(Table1[Fruit]=G2)*(Table1[[#Headers],[Jan]:[Mar]]=H2*(Table1[[Jan]:[Mar]])". Does it work for you?
 
Upvote 0
I'm glad to help you. I appreciate your kind comments.
 
Upvote 0

Forum statistics

Threads
1,223,895
Messages
6,175,257
Members
452,625
Latest member
saadat28

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