Dave Brock
Dave Brock

Reputation: 387

How to add numerical values mapped to similar strings

I dumped a SQL query into Excel and am looking for a way to automate this.

Here's what I have.

site                             12
site/subsite                     22
another site                     77
another site/subsite             16

My question is this: is there a way in Excel to add totals for the site and its associated subsite? I have about 4000 rows so am looking to save manual labor.

Upvotes: 0

Views: 123

Answers (1)

Jon Crowell
Jon Crowell

Reputation: 22358

Use the SUMIF() function.

Here is an example that can get you started:

Put your data in columns A and B (sites in A, values in B).

Add a column header in cell D1 that matches one of the sites names exactly.

Add this formula in cell D2:

=SUMIF($A6:$B17, D1, $B6:$B17)

Modify the start and end rows to cover your entire data set. (In the example I set up, the data was in rows 6 through 17.)

You can list all of your sites and subsites and have formulas refer to the data range to calculate totals for each.

Upvotes: 1

Related Questions