## Data Cubes: operations on cubes

### Slicing

**Slicing** refers to selecting a subset of the cube by choosing a single value for all but two of its dimensions. The result is that you create a slice of the cube, where only two dimensions remain “free” and the data can be visualized as a table.

Going back to the data cube for the Olympics that we used as an example (shown on the left below), if we limit ourselves to only those three dimensions that are shown, some of the ways in which this cube could be sliced are illustrated here:

- Sliced along the Year dimension for the value 2004 (top)
- Sliced along the Medal colour dimension for the value Silver (middle)
- Sliced along the Country dimension for the value GB (bottom)

### Dicing

**Dicing** refers to selecting a subset of the cube by choosing two or more values for multiple dimensions of the cube. The resulting cube has the same number of dimensions, but contains a smaller set of data than the original cube.

The illustration below shows our original Olympics data cube on the left, diced along the following selection of values on the right:

- Values gold and silver for the Medal colour dimension (top)
- Values USA and GB for the Country dimension, gold and bronze for Medal colour, and 2012 and 2004 for Year (bottom).

### Roll-up

A **roll-up** involves summarizing the data along a dimension. The summarization rule might be computing totals along a hierarchy, or applying a set of formulas such as "profit = sales - expenses".

In our Olympics data cube, some examples of roll-up are:

- Gold, silver, and bronze medals could be rolled up into just 1 number for Medals
- Gender as a roll-up of male and female
- Gold medals as a roll-up of medals won at Olympics and Paralympics
- The details of countries could be completely removed by just rolling it up into “All countries” resulting in a table showing only the years and the different colours of medals.

### Drill-down

**Drill-down** refers to the exploration of more detailed data, starting from summary data at a higher level in the hierarchy.

Again, in our Olympics data cube, some examples of drill-down are:

- Going from the total amount of gold medals to the amounts of gold medals won by male athletes and female athletes as separate numbers
- Going from the total amount of gold medals to the amounts of gold medals won at Olympics or Paralympics as separate numbers
- Going from the total amount of medals to the separate amounts of gold, silver, and bronze medals, then further into separate amounts for Olympics and Paralympics, then further down to separate amounts for male and female athletes, and so on.

### Pivoting

When we rotate a data cube in space, this is called **pivoting**. Pivoting allows us to get another perspective on the data.

Looking at our example cube, if we look at the side of the cube that shows the three types of medals for the three countries for 2012, we have the countries shown as rows, and the medals as columns. Pivoting the cube 90 degree clockwise gives us the same data, but now the countries are shown as columns, and medals as rows. If we pivot that towards us by 90 degrees, countries are still shown as columns, but the rows now show the years.

The underlying data remain unchanged. Pivoting just allows us to see them in different ways.