[Solved] SUMIF across multiple sheets

Discuss the spreadsheet application

[Solved] SUMIF across multiple sheets

Postby BFras914 » Wed Nov 17, 2010 1:50 pm

I've searched all over the forum and can't find a topic that matches what I'm trying to do. I apologize if this has been covered elsewhere.

I have a Calc file with one sheet for each week of the year. Each of these 52 sheets contains sales data for several thousand items. For simplicity's sake, I'll focus on the two relevant columns: column A contains an item number, and column B contains that item's sales totals for the week.

I also have an Annual Totals sheet, on which Column A contains every unique item number that occurs on any of the 52 weekly sheets, and I want Column B to add up all sales totals for that item number from the weekly sheets.

This would be easy if every sheet contained the same items, as I could use a formula like SUM(Wk1.B2:Wk52.B2). But my challenge is that not every item is sold every week. I import the weekly data from a report that only lists items with sales, so I can't have each week's sheet set up exatly the same, which would allow me to use that type of SUM formula.

I'm trying to figure out if a similar formula can be done using SUMIF (or some other function). Basically, I want a formula in Column B on my Totals sheet that will look for the value in column A and add up the totals from Column B on all 52 weekly sheets for each occurrence of that value. I know I could accomplish this goal with something like:


But I really don't want to type out that whole formula, and it's probably over the character limit for a formula anyway.

The only other option I can think of right now is to combine all of my weekly data into one sheet and then use a SUMIF to pull the totals from that sheet. But I need to keep a separate sheet for each week, so I don't want to combine all of that detail into one sheet if it's not necessary.

Thanks in advance for any advice!
Last edited by BFras914 on Wed Nov 17, 2010 4:38 pm, edited 1 time in total.
OpenOffice 3.2 on Windows XP
Posts: 3
Joined: Wed Nov 17, 2010 1:31 pm

Re: SUMIF across multiple sheets

Postby keme » Wed Nov 17, 2010 4:20 pm

The best way would be to use a database, but I appreciate the simplicity and freedom of using a spreadsheet.

The second best way, as you say, would be to have everything in one sheet. You could use a data filter to select only a specific week's data. However you have already set up your system with one sheet for each week, so I guess that's how it will be.

The next possibility is to have one SUMIF() on each weekly sheet. If you create it on one sheet, using absolute addressing for the test data, you can copy that to all the other weekly sheets. Have it in the same position on every sheet, and you can use the SUM() across sheets that you suggested.
Apache OO 3.4.1/4.1.2/4.1.3, on Ms Windows 7/10 and Mac OS-X 10.8.5 and 10.11.
LibreOffice on Mepis Antix MX 14
User avatar
Posts: 3397
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: SUMIF across multiple sheets

Postby BFras914 » Wed Nov 17, 2010 4:38 pm

That last suggestion is probably the best option for the way I have this setup. I hadn't thought of that, but I think it might work. Thanks for the idea!

When I started gathering data for this particular project, no one knew exactly what they wanted the end result to look like. So unfortunately I did a lot of my spreadsheet setup and formatting before we had a reall end result in mind. So rather than completely starting from scratch, I'm just trying to find the best way to minimize the work required when we update the data every week in the future. I would definitely have done it differently if I'd known in advance what we were ultimately trying to get to.
OpenOffice 3.2 on Windows XP
Posts: 3
Joined: Wed Nov 17, 2010 1:31 pm

Re: [SOLVED] SUMIF across multiple sheets

Postby Villeroy » Wed Nov 17, 2010 4:51 pm

menu:Data>Consolidation can aggregate (sum, count, average,...) equally structured data from more than one list.
In the dialog you specify the source lists and how to aggregate them (e.g. group by by persons and sum amounts for persons).
I never used that feature. Database are much easier to use (but not as easy to create though).
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Posts: 29090
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [SOLVED] SUMIF across multiple sheets

Postby mriosv » Wed Nov 17, 2010 7:54 pm

Find attached a file with an array formula to sum from several sheets.
Needs a structured name of sheet to sum ending in consecutive numbers, for example: Week1 Week2 ... Week52
And adapt de formula to the specific situation. Number of sheets to sum [COLUMN(A$1:E$1)], and max number of row [ROW(A$1:A$500)] with data in the sheets to sum.
Use Ctrl+Enter to introduce the formula.
(11.75 KiB) Downloaded 872 times
LibreOffice 3.5.4 AOo-3.4 on Win 7 Ultimate
Posts: 651
Joined: Mon Mar 09, 2009 1:12 am
Location: Galiza (España)

Re: [Solved] SUMIF across multiple sheets

Postby Alex1 » Thu Nov 18, 2010 12:04 am

52 times several thousand items is probably more than 65536, the number of rows Calc can handle, but version 3.3, which is expected soon, can handle more rows. Then you can put all sales on one sheet, and use the Data Pilot to calculate the sales totals, without entering any formula. Attached is an example. The totals table on the second sheet is created using the Data Pilot: select columns A to C on the first sheet, click Data, Data Pilot, Start, choose Current selection, Ok, drag the Items button to Row fields, and the Sales button to the Data field. Under More, select Results to new sheet, check Ignore empty rows, Ok. The weeks column is optional.
(8.78 KiB) Downloaded 541 times
AOO 4.1.7 & LO 5.0.6 on Windows XP & 7
Posts: 608
Joined: Fri Feb 26, 2010 1:00 pm
Location: Netherlands

Return to Calc

Who is online

Users browsing this forum: No registered users and 17 guests