HLOOKUP in Access 2013

AndyDevine1

Board Regular
Joined
Jun 1, 2006
Messages
172
Hi there

To simplify, I have three fields in my table:

Column A "Item" contains
A2 - Item 1
A3 - Item 2


Column B contains the heading "Item 1" and then values in B2 (eg 100) and B3 (eg 50)
Column C contains the heading "Item 2" and then values in C2 (eg 11) and C3 (eg 12)

I want to report on the totals for each column (B, C etc)

So I want Item 1 total = 100 + 150 = 150
And item 2 total = 11 + 12 = 25

Can I do this via a horizontal look up or similar?

Thanks for reading

Andy
 
I changed the table slightly:


Excel 2010
ABCDEFGHIJKLMNOPQRSTU
1ItemGroup 1Group 2Group 3Group 4Group 5Group 6Group 7Group 8Group 9Group 10Group 11Group 12Group 13Group 14Group 15Group 16Group 17Group 18Group 19Group 20
214247741384197982317997355352435497336
32261141789984273424552695335681526824652
43525410775211941123562866339199387226
5433264284617917546024432520873242438675
6548689673637434225885849661302317812820
7666892749573562884143264691669027619962
879768461699531004617279869286426664598127
98816679393752519966494936562437974817684
1092663965915779491211943917894237129150
1110532440907271768472420707290755234510
12114171596527831131635230543446823995668115
13122260534279945386163570492917265743934
1413100838526224452130494031621317840864451
151460107916537695375276922862116669862787
1615824325478696653801510060269972241827199
171621237047659516166346413591643552489619
181756373028675055693559791613895810830
1918238734758654429353070459134106661941964
2019535270281134329831563533552156054153735
212097547622545514394909611996411104963776
Data


With Data as the table name, paste this into sql view of a blank query:

Code:
SELECT Data.Item, 1 AS [Group], Data.[Group 1] AS [Number]
FROM Data;
union
SELECT Data.Item, 2 AS [Group], Data.[Group 2] AS [Number]
FROM Data;
union
SELECT Data.Item, 3 AS [Group], Data.[Group 3] AS [Number]
FROM Data;
union
SELECT Data.Item, 4 AS [Group], Data.[Group 4] AS [Number]
FROM Data;
union
SELECT Data.Item, 5 AS [Group], Data.[Group 5] AS [Number]
FROM Data;
union
SELECT Data.Item, 6 AS [Group], Data.[Group 6] AS [Number]
FROM Data;
union
SELECT Data.Item, 7 AS [Group], Data.[Group 7] AS [Number]
FROM Data;
union
SELECT Data.Item, 8 AS [Group], Data.[Group 8] AS [Number]
FROM Data;
union
SELECT Data.Item, 9 AS [Group], Data.[Group 9] AS [Number]
FROM Data;
union
SELECT Data.Item, 10 AS [Group], Data.[Group 10] AS [Number]
FROM Data;
union
SELECT Data.Item, 11 AS [Group], Data.[Group 11] AS [Number]
FROM Data;
union
SELECT Data.Item, 12 AS [Group], Data.[Group 12] AS [Number]
FROM Data;
union
SELECT Data.Item, 13 AS [Group], Data.[Group 13] AS [Number]
FROM Data;
union
SELECT Data.Item, 14 AS [Group], Data.[Group 14] AS [Number]
FROM Data;
union
SELECT Data.Item, 15 AS [Group], Data.[Group 15] AS [Number]
FROM Data;
union
SELECT Data.Item, 16 AS [Group], Data.[Group 16] AS [Number]
FROM Data;
union
SELECT Data.Item, 17 AS [Group], Data.[Group 17] AS [Number]
FROM Data;
union
SELECT Data.Item, 18 AS [Group], Data.[Group 18] AS [Number]
FROM Data;
union
SELECT Data.Item, 19 AS [Group], Data.[Group 19] AS [Number]
FROM Data;
UNION SELECT Data.Item, 20 AS [Group], Data.[Group 20] AS [Number]
FROM Data;

then paste this into another blank query:

Code:
SELECT DISTINCTROW [Data Query2].Group, Sum([Data Query2].Number) AS [Sum Of Number]
FROM [Data Query2]
GROUP BY [Data Query2].Group;

Databases efficiently store and present 1 to 1 data, not the 2-dimensional table you started with. This is a common problem, which later versions of Access might handle better, perhaps with the table analyzer to "normalize".
 
Upvote 0

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I changed the table slightly:


Excel 2010
ABCDEFGHIJKLMNOPQRSTU
1ItemGroup 1Group 2Group 3Group 4Group 5Group 6Group 7Group 8Group 9Group 10Group 11Group 12Group 13Group 14Group 15Group 16Group 17Group 18Group 19Group 20
214247741384197982317997355352435497336
32261141789984273424552695335681526824652
43525410775211941123562866339199387226
5433264284617917546024432520873242438675
6548689673637434225885849661302317812820
7666892749573562884143264691669027619962
879768461699531004617279869286426664598127
98816679393752519966494936562437974817684
1092663965915779491211943917894237129150
1110532440907271768472420707290755234510
12114171596527831131635230543446823995668115
13122260534279945386163570492917265743934
1413100838526224452130494031621317840864451
151460107916537695375276922862116669862787
1615824325478696653801510060269972241827199
171621237047659516166346413591643552489619
181756373028675055693559791613895810830
1918238734758654429353070459134106661941964
2019535270281134329831563533552156054153735
212097547622545514394909611996411104963776
Data


With Data as the table name, paste this into sql view of a blank query:

Code:
SELECT Data.Item, 1 AS [Group], Data.[Group 1] AS [Number]
FROM Data;
union
SELECT Data.Item, 2 AS [Group], Data.[Group 2] AS [Number]
FROM Data;
union
SELECT Data.Item, 3 AS [Group], Data.[Group 3] AS [Number]
FROM Data;
union
SELECT Data.Item, 4 AS [Group], Data.[Group 4] AS [Number]
FROM Data;
union
SELECT Data.Item, 5 AS [Group], Data.[Group 5] AS [Number]
FROM Data;
union
SELECT Data.Item, 6 AS [Group], Data.[Group 6] AS [Number]
FROM Data;
union
SELECT Data.Item, 7 AS [Group], Data.[Group 7] AS [Number]
FROM Data;
union
SELECT Data.Item, 8 AS [Group], Data.[Group 8] AS [Number]
FROM Data;
union
SELECT Data.Item, 9 AS [Group], Data.[Group 9] AS [Number]
FROM Data;
union
SELECT Data.Item, 10 AS [Group], Data.[Group 10] AS [Number]
FROM Data;
union
SELECT Data.Item, 11 AS [Group], Data.[Group 11] AS [Number]
FROM Data;
union
SELECT Data.Item, 12 AS [Group], Data.[Group 12] AS [Number]
FROM Data;
union
SELECT Data.Item, 13 AS [Group], Data.[Group 13] AS [Number]
FROM Data;
union
SELECT Data.Item, 14 AS [Group], Data.[Group 14] AS [Number]
FROM Data;
union
SELECT Data.Item, 15 AS [Group], Data.[Group 15] AS [Number]
FROM Data;
union
SELECT Data.Item, 16 AS [Group], Data.[Group 16] AS [Number]
FROM Data;
union
SELECT Data.Item, 17 AS [Group], Data.[Group 17] AS [Number]
FROM Data;
union
SELECT Data.Item, 18 AS [Group], Data.[Group 18] AS [Number]
FROM Data;
union
SELECT Data.Item, 19 AS [Group], Data.[Group 19] AS [Number]
FROM Data;
UNION SELECT Data.Item, 20 AS [Group], Data.[Group 20] AS [Number]
FROM Data;

then paste this into another blank query:

Code:
SELECT DISTINCTROW [Data Query2].Group, Sum([Data Query2].Number) AS [Sum Of Number]
FROM [Data Query2]
GROUP BY [Data Query2].Group;

Databases efficiently store and present 1 to 1 data, not the 2-dimensional table you started with. This is a common problem, which later versions of Access might handle better, perhaps with the table analyzer to "normalize".





Thank you so much for this, really appreciate it. Will try this Monday, cheers
 
Upvote 0
Hi, thanks again, this works brilliantly...

Would you be able to help me some more - imagine the same scenario with heading 1, heading 2, heading 3 running left to right in columns but instead saying heading 1 - holidays, heading 1 - events, heading 1 - other, then same for all other headings...heading 2- holidays, heading 2 - events, heading 2 - other etc, etc....

When the query is run, the list then becomes

Column A - headings (heading 1, heading 2, heading 3 etc), Column B - type (Holidays, events or other) and Column C the value for each?

Many thanks

Andy
 
Upvote 0
Would you be able to help me some more?
The scenario is bit more involved…instead of columns with headings running left to right - heading 1, heading 2, heading 3 etc the structure is:
Headings D onwards: “heading 1 – holidays”, “heading 1 – events”, “heading 1 – other”, then same for all other headings...”heading 2- holidays”, “heading 2 – events”, “heading 2 – other” etc, etc....

When the query is run, the list then becomes
Column A - headings (heading 1, heading 2, heading 3 etc)
Column B – Product Type (Holidays, events or other)
Column C - The total number of each…eg total number of holidays for heading 1, total number of events for heading 1, total number of ‘other’ for heading 1 and so on…

Many thanks

Andy
 
Upvote 0

Forum statistics

Threads
1,221,893
Messages
6,162,659
Members
451,780
Latest member
Blake86

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