0% found this document useful (0 votes)
33 views4 pages

OLAP Example

OLAP Theory for Engineering.

Uploaded by

mr.jhion.adbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views4 pages

OLAP Example

OLAP Theory for Engineering.

Uploaded by

mr.jhion.adbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

OLAP Example: Converting Tabular Data

to Multidimensional Array
Online Analytical Processing (OLAP) involves analyzing data in multiple dimensions. Here's
a simple example to illustrate the conversion of tabular data into a multidimensional array.

Tabular Data Example:


We have a sales dataset with the following columns:
- Product (Product category)
- Region (Sales region)
- Year (Sales year)
- Sales (Total sales)

Product Region Year Sales


Laptop North 2021 1000
Laptop South 2021 1500
Laptop North 2022 1200
Phone South 2021 800
Phone North 2021 900
Phone South 2022 1100

Step 1: Identify Dimensions and Measures


Dimensions: Product, Region, Year
Measure: Sales

Step 2: Convert to a Multidimensional Array


Now, let’s build a 3D cube with the following dimensions:
- Product dimension: [Laptop, Phone]
- Region dimension: [North, South]
- Year dimension: [2021, 2022]

Each cell in the cube will contain the sales measure for a specific combination of Product,
Region, and Year.
3D Cube Representation:
2021 2022
Laptop North 1000 1200
Laptop South 1500 -
Phone North 900 -
Phone South 800 1100

OLAP Operations
OLAP (Online Analytical Processing) involves performing complex queries on
multidimensional data. The following are the core OLAP operations applied to a simple
multidimensional array or data cube.

1. Slice Operation
The slice operation reduces the dimensionality of the cube by selecting a single value for
one of the dimensions. For example, if we want to examine sales only for the year 2021, we
would 'slice' the cube by fixing the value of the Year dimension to 2021.

Example (Slicing by Year 2021):


After slicing the cube, you get a 2D table showing the sales for both Laptop and Phone
across the North and South regions for the year 2021:
| Product | Region | Sales (2021) |
|----------|--------|--------------|
| Laptop | North | 1000 |
| Laptop | South | 1500 |
| Phone | North | 900 |
| Phone | South | 800 |

2. Dice Operation
The dice operation selects specific values across multiple dimensions, creating a smaller
sub-cube. This allows you to focus on particular slices of the data by selecting multiple
values for each dimension.

Example (Dicing by Product = Laptop and Region = North):


You create a sub-cube that contains sales of Laptop in the North region across the years
2021 and 2022:
| Year | Sales |
|------|-------|
| 2021 | 1000 |
| 2022 | 1200 |

3. Drill Down Operation


The drill down operation allows you to navigate from more summarized data to more
detailed data by focusing on finer levels of granularity. For instance, you can start with
aggregated sales for a product and then drill down into more detail by considering sales per
region or per year.

Example (Drilling Down from Product to Product and Region):


Initially, you have total sales for Laptop. When you drill down, you see the sales for Laptop
broken down by North and South regions, and even further by Year:
| Product | Region | Year | Sales |
|----------|---------|------|-------|
| Laptop | North | 2021 | 1000 |
| Laptop | North | 2022 | 1200 |
| Laptop | South | 2021 | 1500 |

4. Roll Up Operation
The roll up operation is the reverse of drill down. It involves aggregating data to get a
higher-level summary. Instead of looking at specific sales for a product in a region for each
year, you might roll up to look at the total sales for each product, regardless of region or
year.

Example (Rolling Up Sales by Product):


You aggregate the sales across all years and regions to see the total sales of Laptop and
Phone:
| Product | Total Sales |
|----------|-------------|
| Laptop | 3700 |
| Phone | 2800 |

5. Pivot Operation
The pivot operation changes the perspective of the data by rotating the cube. This helps in
viewing the data from a different angle. For example, instead of viewing the data by Product
as the primary dimension, you could pivot the cube to view the data with Year as the
primary dimension.

Example (Pivoting the Cube by Year):


Instead of focusing on products, the cube is now structured to display sales by year first,
with Product and Region being secondary dimensions:
| Year | Product | Region | Sales |
|------|----------|--------|-------|
| 2021 | Laptop | North | 1000 |
| 2021 | Laptop | South | 1500 |
| 2021 | Phone | North | 900 |
| 2021 | Phone | South | 800 |
| 2022 | Laptop | North | 1200 |
| 2022 | Phone | South | 1100 |

Conclusion
OLAP operations provide powerful tools for analyzing multidimensional data, enabling
users to slice, dice, drill down, roll up, and pivot data for better insights and decision-
making.

You might also like