Sumif based on column headers then converted to a table

ExcelAmateur2020

New Member
Joined
Jun 8, 2020
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hope I can explain this properly

Tab 1 has headed columns 1 - 38 (any football fans may recognise this as the number of gameweeks in the premier league season!). Each row then contains a number (1 - 5) based on the difficulty of a team's fixture in that week.

I want tab 2 to allow the user to enter a "from" and "to" week to see the total difficulty in that range (ie from 5 - 10 would return the values from columns headed 5,6,7,8,9&10).

Any help appreciated
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Complete novice so this may not work and I can not work out how to share a sheet sorry but here we go. In image 2 I want to be able to update values in B1 and B2 to then sum the equivalent values. For example based on current parameters ARS should read 7 (1 + 1 +5) in image 2 where I currently have a sumifs formula that is not working!
Image 2.png
Image 1.png
 
Upvote 0
with Power Query aka Get&Transform

Labels123456789101112131415161718FromLabelsSum
ARS1154545113433242131ARS7
AVL1041541352113313454AVL15
BHA415231431534141535ToBHA10
BUR10431144235251314153BUR17
CHE251335341412315154CHE8
CRY352421313114151445CRY10
EVE413253151134454513EVE8
FUL511343112455213435FUL7
LEE514531435241153143LEE10
LEI135115135142245314LEI9
LIV145124154231431133LIV10
MCI1034151454315131242MCI17
MUN1032414521315414311MUN15
NEW124353234311115544NEW7
SHU311515541143522331SHU5
SOU343142113524551151SOU10
TOT231513215453543111TOT6
WBA424332145431515151WBA10
WHU153445514151342321WHU9
WOL451111343551434522WOL10

Power Query:
let
    From = Excel.CurrentWorkbook(){[Name="From"]}[Content],
    To = Excel.CurrentWorkbook(){[Name="To"]}[Content],
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    UOC = Table.UnpivotOtherColumns(Source, {"Labels"}, "Attribute", "Value"),
    Type = Table.TransformColumnTypes(UOC,{{"Attribute", Int64.Type}}),
    Select = Table.AddColumn(Type, "Select", each List.Select({[Attribute]}, each (_ >= From[From]{0} and _ <= To[To]{0}))),
    Expand = Table.ExpandListColumn(Select, "Select"),
    FilterNull = Table.SelectRows(Expand, each ([Select] <> null)),
    Group = Table.Group(FilterNull, {"Labels"}, {{"Sum", each List.Sum([Value]), type number}})
in
    Group
 
Upvote 0
with Power Query aka Get&Transform

Labels123456789101112131415161718FromLabelsSum
ARS1154545113433242131ARS7
AVL1041541352113313454AVL15
BHA415231431534141535ToBHA10
BUR10431144235251314153BUR17
CHE251335341412315154CHE8
CRY352421313114151445CRY10
EVE413253151134454513EVE8
FUL511343112455213435FUL7
LEE514531435241153143LEE10
LEI135115135142245314LEI9
LIV145124154231431133LIV10
MCI1034151454315131242MCI17
MUN1032414521315414311MUN15
NEW124353234311115544NEW7
SHU311515541143522331SHU5
SOU343142113524551151SOU10
TOT231513215453543111TOT6
WBA424332145431515151WBA10
WHU153445514151342321WHU9
WOL451111343551434522WOL10

Power Query:
let
    From = Excel.CurrentWorkbook(){[Name="From"]}[Content],
    To = Excel.CurrentWorkbook(){[Name="To"]}[Content],
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    UOC = Table.UnpivotOtherColumns(Source, {"Labels"}, "Attribute", "Value"),
    Type = Table.TransformColumnTypes(UOC,{{"Attribute", Int64.Type}}),
    Select = Table.AddColumn(Type, "Select", each List.Select({[Attribute]}, each (_ >= From[From]{0} and _ <= To[To]{0}))),
    Expand = Table.ExpandListColumn(Select, "Select"),
    FilterNull = Table.SelectRows(Expand, each ([Select] <> null)),
    Group = Table.Group(FilterNull, {"Labels"}, {{"Sum", each List.Sum([Value]), type number}})
in
    Group

This is obviously absolutely amazing but I have literally no idea how to get that in to the sheet... I was really hoping to achieve it with a formula rather than macro / power query. Perhaps that is not possible. Seriously thanks so much though.
 
Upvote 0
This is obviously absolutely amazing but I have literally no idea how to get that in to the sheet... I was really hoping to achieve it with a formula rather than macro / power query. Perhaps that is not possible. Seriously thanks so much though.
sure, good luck with formula
anyway here is an example: s666-PQ-Sum selected rows.xlsx
after change From / To right click on green table and select Refresh
 
Last edited:
Upvote 0
How about
+Fluff New.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXY
1123456789101112131415161718From1Sum
2ARS115454511343324213To3ARS7
3AVL1041541352113313454AVL15
4BHA415231431534141535BHA10
5BUR1043114423525131415BUR17
6CHE251335341412315154CHE8
7CRY352421313114151445CRY10
8EVE413253151134454513EVE8
9FUL511343112455213435FUL7
10LEE514531435241153143LEE10
11LEI135115135142245314LEI9
12LIV145124154231431133LIV10
13MCI1034151454315131242MCI17
14MUN1032414521315414311MUN15
15NEW124353234311115544NEW7
16SHU311515541143522331SHU5
17SOU343142113524551151SOU10
18TOT231513215453543111TOT6
19WBA424332145431515151WBA10
20WHU153445514151342321WHU9
21WOL451111343551434522WOL10
Master
Cell Formulas
RangeFormula
X2:X21X2=UNIQUE(A2:A21)
Y2:Y21Y2=SUM(FILTER(FILTER($C$2:$T$21,$A$2:$A$21=$X2),($C$1:$T$1>=$W$1)*($C$1:$T$1<=$W$2)))
Dynamic array formulas.
 
Upvote 0
How about
+Fluff New.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXY
1123456789101112131415161718From1Sum
2ARS115454511343324213To3ARS7
3AVL1041541352113313454AVL15
4BHA415231431534141535BHA10
5BUR1043114423525131415BUR17
6CHE251335341412315154CHE8
7CRY352421313114151445CRY10
8EVE413253151134454513EVE8
9FUL511343112455213435FUL7
10LEE514531435241153143LEE10
11LEI135115135142245314LEI9
12LIV145124154231431133LIV10
13MCI1034151454315131242MCI17
14MUN1032414521315414311MUN15
15NEW124353234311115544NEW7
16SHU311515541143522331SHU5
17SOU343142113524551151SOU10
18TOT231513215453543111TOT6
19WBA424332145431515151WBA10
20WHU153445514151342321WHU9
21WOL451111343551434522WOL10
Master
Cell Formulas
RangeFormula
X2:X21X2=UNIQUE(A2:A21)
Y2:Y21Y2=SUM(FILTER(FILTER($C$2:$T$21,$A$2:$A$21=$X2),($C$1:$T$1>=$W$1)*($C$1:$T$1<=$W$2)))
Dynamic array formulas.
Smashed it. This works perfectly thank you so much
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,692
Members
448,979
Latest member
DET4492

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