# Re: how to compute totals grouped by field?

• From: "Andreas J. Guelzow" <aguelzow pyrshep ca>
• To: gnumeric-list gnome org
• Subject: Re: how to compute totals grouped by field?
• Date: Sat, 10 Jan 2009 11:32:32 -0700

```On Sun, 2009-01-11 at 02:07 +1100, Hal Ashburner wrote:
```
```Adam Dingle wrote:
```
```In Gnumeric, suppose that I have a series of rows representing
payments to vendors.  Each row contains a date, a vendor name and a
payment:

4/3   XyzCo   4.15
4/4   AbcCo   8.20
4/5   XyzCo   2.25
....

I'd like to construct a table showing each vendor and the total of all
payments ever made to that vendor:

XyzCo  6.40
AbcCo  8.20
...

Is this possible in Gnumeric?
```
```Yes, there are a couple of ways to do this.
One way is to enter an array function to conditionally sum.
if XyzCo is in cell A7, and other companies below then this formula:

=sum(if(\$A7=\$B\$1:\$B\$3,\$C\$1:\$C\$3,0))
which you enter using ctrl+shift+enter so it will then appears like this:
{=sum(if(\$A7=\$B\$1:\$B\$3,\$C\$1:\$C\$3,0))}(1,1)[0][0]

will do the job. This also works in competing spreadsheet packages so is
quite portable.
```
```Or must I export to an SQL database and execute a query such as
'select sum(payment) GROUP BY vendor', which would have a similar effect?

```
```
As of 1.9.3 you can use the frequency tool (from the stats tools) to
have these formulas created for you.

Andreas
--

```

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]