Articles

OLAP cubes: how they work, which kinds exist and how to build one

What an OLAP cube is: measures, dimensions, hierarchies, MOLAP, ROLAP, HOLAP and tabular models, a step-by-step build and common mistakes.

65 min readSergiy Belyakov

The director asks: fourth-quarter sales by region, against last year, split by category. An analyst writes a query over several million rows. The next question is slightly different, and the query is new again. In a week there are dozens of such queries, each with its own logic.

An OLAP cube (Online Analytical Processing) solves this differently. It lays the data out in advance along the axes the business thinks in: time, product, territory. The director’s question becomes a set of coordinates, and the answer sits in a cell. Below: how a cube is built inside, which kinds exist, how to build one step by step and where people most often go wrong.

What an OLAP cube is

A cube has a few parts:

  • Measures: the numbers being calculated. Sales amount, quantity, margin.
  • Dimensions: the axes measures are cut by. Date, product, region.
  • Hierarchies: levels inside a dimension. Year → quarter → month → day, category → product, region → city.
  • Members: specific values at a level. “Q4 2026”, “Laptops”, “Kyiv”.
  • Cells: the intersection of members of all dimensions. The value of a measure in a cell answers one question.
  • Aggregates: totals at the upper levels of hierarchies. A quarter rather than a day; a region rather than a city.
STAR SCHEMASalesfacts: amount, quantityDateyear → quarter → monthProductcategory → productRegionregion → cityCUBEDate →← ProductRegion ↑Q4 2026 · Laptops · Kyivamount 1,240k
A made-up example. A star schema becomes a cube: each dimension is an axis, and the answer to a question sits in the cell where they meet.

An analogy: an Excel pivot table that someone has already calculated for every possible combination of rows and columns. The analogy is imperfect, because there are usually more than three dimensions, and the word “cube” is just a visual aid: it is not geometry but a way of addressing numbers.

Importantly, a cube is almost always built on a star schema: a fact table in the centre, dimension tables around it. A cube does not replace a well-modelled warehouse. It sits on top of it.

Five operations it is built for

Operation What it does Example question
Slice fixes one member of one dimension “Only 2026”
Dice restricts several dimensions at once “Q3 and Q4, laptops and tablets, Kyiv and Lviv”
Drill-down goes to a lower level of a hierarchy “Split Q4 into months”
Roll-up goes to a higher level “Add cities up into regions”
Pivot swaps the axes “Regions in rows, months in columns”
Sliceonly the year 2026Dice2 quarters × 2 categories × 2 regionsOctNovDecQ4Drill-downQ4 opens into monthsRegionΣ citiesRoll-upcities add up to regions
Four operations on the same cube: slice, dice, drill-down and roll-up.

Users do this by clicking in a pivot table or a report. Under the hood every click becomes a query to the cube, and the response time depends on where the detail and the aggregates live.

Kinds of cubes

MOLAP (Multidimensional OLAP). Both detail and aggregates are copied into the cube’s own multidimensional storage. Answers to typical questions are very fast, because aggregates are precomputed. The price: processing takes time, and data is only as fresh as the last processing run.

ROLAP (Relational OLAP). The cube only describes dimensions and measures, and the data stays in a relational database. Every question is translated into SQL. Data is always fresh and volume is almost unlimited, but speed depends on the database and its indexes.

HOLAP (Hybrid OLAP). Detail stays in the database, aggregates are stored in the cube. Totals are fast, and drilling down to a row goes to the database.

Tabular models. The modern option from Microsoft: SSAS Tabular, Azure Analysis Services and Power BI semantic models. Data is compressed by column in memory by the VertiPaq engine, and aggregates are calculated on the fly, because columnar compression makes that fast enough. The formula language is DAX, not MDX. People still call them cubes, although inside they are tables and relationships.

TYPEDETAILAGGREGATESMOLAPin the cubein the cube, precomputedROLAPin the relational DBin the DB, via SQLHOLAPin the relational DBin the cube, precomputedTabularin memory, by columncomputed on the flyThe query goes where the answer lives
OLAP types differ in where detail and aggregates live, and that is where the query goes.

Where things stand in 2026: SSAS multidimensional mode (MDX) is still part of SQL Server and supported, but Microsoft puts new capabilities into tabular models. Azure Analysis Services and Power BI work with tabular models only; Power BI can connect live to an existing multidimensional cube. That is why on the Microsoft stack I almost always start a new project with a semantic model rather than a classic cube.

Cube-like approaches beyond Microsoft. The idea of precomputed aggregates lives on in other tools:

  • Apache Kylin precomputes sets of aggregates (cuboids) over big data and answers SQL from them.
  • Apache Druid can roll data up at ingestion: instead of every event it stores a total per minute or hour.
  • ClickHouse is a columnar OLAP database: it aggregates on the fly, and the most frequent questions are kept in materialised views.
  • Semantic layers describe measures and dimensions once, and queries go to the warehouse.
  • In Power BI you can add aggregation tables on top of DirectQuery detail: the model picks where to answer from.

How a cube is built: a step-by-step example

A made-up example: a distributor, three years of sales, 200 products, 25 regions.

1. Questions and grain. First, the questions the cube must answer, and the grain of the fact table: one row is “day × product × outlet”. The grain sets how deep you can drill. The cube will never go below it.

2. Star schema. A “Sales” fact table with keys and numbers. “Date”, “Product” and “Region” dimensions with attributes. Surrogate keys, and every dimension has an “Unknown” row for empty references.

3. Measures and aggregation rules. Sales amount and quantity add up across all dimensions (additive). Stock on hand cannot be added up over time: for a quarter it is the closing balance, not the sum of three months (semi-additive). A distinct count of customers does not add up at all: a customer who bought in Kyiv and in Lviv is one customer in the region total and two in the sum.

4. Hierarchies and attribute relationships. Year → quarter → month → day. Category → subcategory → product. Region → city → outlet. Relationships between levels must be strict: every month belongs to one quarter, every city to one region. Otherwise the totals drift apart.

5. Calculated measures. Margin, share of total, change against last year. They are defined once in the cube so that each report does not carry its own version of the formula. In MDX these are calculated members, in DAX measures:

Sales last year :=
CALCULATE (
    [Sales amount],
    SAMEPERIODLASTYEAR ( 'Date'[Date] )
)

6. Partitions. The fact table is split into parts, usually by month. Only the latest partitions are refreshed, the old ones stay as they are. In Power BI this is incremental refresh.

7. Aggregations. In a multidimensional cube you choose which combinations of levels to precompute. You cannot compute them all: the number of combinations grows as the product of the levels of all dimensions. You compute the ones frequent questions need.

8. Processing and refresh. The cube loads data from the warehouse and computes aggregates on a schedule: fully every night, or only the new partitions. Between runs the cube shows the state as of the last refresh, and the report should say so.

9. Security roles. Who sees what is set by roles on dimensions, as described in the article on row-level security.

10. The query. The director’s question in MDX:

SELECT
  [Measures].[Sales amount]
    ON COLUMNS,
  [Region].[Region].MEMBERS
    ON ROWS
FROM [Sales]
WHERE
  [Date].[Quarter].&[2026-Q4]

Sparsity is worth counting too. 36 months × 200 products × 25 regions give 180,000 possible cells. If 40,000 combinations really occur, the rest are empty. Modern engines do not store empty cells, but sparsity is a good check on whether the dimensions were chosen well.

Details that decide whether a cube survives

  • Conformed dimensions. One “Date” and one “Region” for all cubes and facts. Then sales and budget can be compared in one report.
  • Slowly changing dimensions. A product moved to another category. Type 1 overwrites the attribute, and all history moves to the new category. Type 2 adds a new version of the row, and past sales stay in the old one. Choose deliberately for each attribute.
  • One grain per fact table. A monthly plan and daily actuals are two fact tables, not one.
  • Logic in one place. The margin formula lives in the cube. Not in a SQL view, not in Excel and not in every report separately.

Common mistakes

  1. A cube on raw tables without a star. Works in the demo, gives duplicates and slow queries on real data.
  2. Stock summed over time. Annual stock comes out 12 times higher than reality.
  3. Distinct customers as a sum. Regions together show more customers than the company has.
  4. Hierarchies without strict relationships. A city with the same name in two regions, and totals drift apart.
  5. Aggregations for everything. Processing takes hours, and most aggregates are never queried.
  6. Full processing every night without partitions. While the cube processes, reports show yesterday’s numbers or do not open.
  7. A cube nobody understands. Twenty dimensions with technical names. Users go back to Excel.

When you need a cube and when you do not

Situation What fits
Millions of rows, Power BI, dozens of reports on the same measures semantic model (tabular)
An SSAS multidimensional cube already exists with reports and Excel on it maintain it and gradually move to a tabular model
Billions of events, answers in seconds, real-time dashboards an OLAP database (ClickHouse, Druid) or precomputed aggregates
Several BI tools must calculate the same way a semantic layer over the warehouse
Hundreds of thousands of rows, one report a well-modelled table, no cube needed

A cube pays off where many people ask different questions of the same measures. If there is one question and one report, a cube adds another layer with no benefit.

Short checklist

  • Questions and grain are written down before modelling.
  • A star schema with conformed dimensions sits under the cube.
  • For every measure you know how it aggregates over time and other dimensions.
  • Hierarchies have strict level relationships.
  • Calculated measures are defined in the cube, not in reports.
  • Partitions and incremental refresh are in place, and the report shows the data date.
  • Aggregations are chosen from real queries.
  • Security roles are tested under real users.

Where to start

Write down the ten questions managers ask most often and look at which measures and dimensions they rest on. If it is the same three or four axes, you need one shared model, not ten queries. How it fits into the overall reporting setup is in the article BI architecture: four options. I help with this as part of business intelligence and data architecture.

Do your reports compute the answer every time, or pick up a ready one?

A similar problem in your team?

Describe the situation in a few sentences. I will reply with where I would start and whether I can help.

Discuss your project

Short weekly notes on data in the Telegram channel (in Ukrainian): @belyakovconsult

All articles

Glossary