Each column for which you define a name must have a corresponding expression; otherwise, an error is returned. The first argument, name, defines the name of the column in the results. The second argument, expression, defines the calculation performed to obtain the value for each row in that column.

groupBy_columnName must be either in table or in a related table to table.

Each name must be enclosed in double quotation marks.

The function groups a selected set of rows into a set of summary rows by the values of one or more groupBy_columnName columns. One row is returned for each group.

The following example returns a summary of the reseller sales grouped around the calendar year and the product category name, this result table allows you to do analysis over the reseller sales by year and product category.

The following table shows a preview of the data as it would be received by any function expecting to receive a table:

DateTime[CalendarYear]

ProductCategory[ProductCategoryName]

[Sales Amount (USD)]

[Discount Amount (USD)]

2008

Bikes

12968255.42

36167.6592

2005

Bikes

6958251.043

4231.1621

2006

Bikes

18901351.08

178175.8399

2007

Bikes

24256817.5

276065.992

2008

Components

2008052.706

39.9266

2005

Components

574256.9865

0

2006

Components

3428213.05

948.7674

2007

Components

5195315.216

4226.0444

2008

Clothing

366507.844

4151.1235

2005

Clothing

31851.1628

90.9593

2006

Clothing

455730.9729

4233.039

2007

Clothing

815853.2868

12489.3835

2008

Accessories

153299.924

865.5945

2005

Accessories

18594.4782

4.293

2006

Accessories

86612.7463

1061.4872

2007

Accessories

275794.8403

4756.6546

2008

15496115.89

41224.3038

2005

7582953.67

4326.4144

2006

22871907.85

184419.1335

2007

30543780.84

297538.0745

76494758.25

527507.9262

ROLLUPGROUP

ROLLUPGROUP() can be used to calculate groups of subtotals. If used in-place of ROLLUP, ROLLUPGROUP will yield the same result by adding roll-up rows to the result on the groupBy_columnName columns. However, the addition of ROLLUPGROUP() inside a ROLLUP syntax can be used to prevent partial subtotals in roll-up rows.

The following example shows only the grand total of all years and categories without the subtotal of each year with all categories: