Ravindra BagaleCourses & study guides मराठी Track your progress

24. Power Pivot and the Data Model

Excel

24.4 Fact and Dimension Tables: the Star Schema

Design a star schema around the question each row answers

Imagine a fictional delivery business with approved sales for each order and current product and store lists. On a flat export, the city appears beside every local order. The field is useful, but someone needs to maintain repeated descriptions and know which edition of the catalog supplied them. A star schema puts approved events or observations in a central fact table and descriptive lookup tables around it. Relationships tell the model how a selection of store, product or date should shape the sales calculation.

Start the design from the report question. If a manager wants sales by city and month, the workbook needs a fact amount at the approved order grain and reliable keys to Stores and Calendar. If the manager also wants Sales by Category, add the relevant Products key. The point is to keep business meaning and relationships visible where reports can reuse them. A star schema can make filters more predictable and reduce repeating attribute fields, while actual performance and file size still depend on the data and workbook.

  • Write the grain first. One row in Orders is one approved order in this fixture. A product line and a whole order require different counts.
  • Use descriptive dimensions for the shared groupings. StoreID links a store record to many Orders facts, while City and Platform supply labels.
  • Keep quantities, amounts and reporting scope clear. Separate data with different row meanings, such as order lines and monthly targets.
Orders is at the center of a star schema. Stores, Products and Calendar relate to Orders on their unique store, product and date keys.
Each dimension relates directly to the central Orders fact. The keys connect the tables. Labels supply reporting choices such as City, Category and Month.

Use the workbook’s original order-grain fixture

Start with the exact twelve-order workbook from 24.1 Power Pivot setup. It has twelve Orders records, four Stores and four Products. For this diagram exercise, sketch the Calendar table covering October 1 through November 30, 2026, a total of 61 consecutive days. The next lesson creates and validates it in Excel. One Calendar row represents one day. A full-year calendar or other broader accepted span can be needed for time analysis. The 61 days here describe the existing two-month practice scope.

Table definitions for the original teaching star. Each one has an explicit row grain.
TableOne row representsKeysExample reports use
OrdersOne approved purchase in this sampleOrderID identifies the fact. StoreID, ProductID and Date refer to dimensions.Qty and Amount, plus order level auditing
StoresOne storeUnique StoreIDCity and Platform
ProductsOne catalog itemUnique ProductIDProduct and Category. Price is a sample catalog attribute.
CalendarOne calendar dateUnique DateYear, Month, Month Number, and year-aware labels

Some training materials call a fact's numeric source fields measures. Within Excel’s model we also use the word measure for a saved DAX calculation. Here Amount is a stored fact column. Total Sales is a calculation that sums it for the current report context. The distinction helps when a reviewer asks whether an original amount can be corrected or whether the calculation itself needs a change. A model can also have facts without numeric amounts, for example a register of attendance events where the count of rows serves as the measure.

Move repeated fields to the right table without changing money

In a flattened copy, O-101 can display Pune, FreshGo, Cow Milk and Dairy on the order row. These labels make an export readable. They are obtained from the key matches. In the star model Orders keeps its identifiers, quantity and recorded sales amount. Stores supplies the approved Pune and FreshGo label. Products supplies the milk description and Dairy category. The same two lookups also serve other fact rows. The actual O-101 amount stays ₹128.

Four original Orders in a readable flat view, expressed through their approved lookup values.
OrderCityPlatformCategoryQtyAmount
O-101PuneFreshGoDairy4128
O-102NashikFreshGoFruits2180
O-103NagpurMarketRushStaples3195
O-104PuneFreshGoSnacks2220

In the original full extract Pune appears on five approved order rows. In the lookup list for this fixture there is one Pune store row. Summing the five approved fact amounts still gives ₹940. All twelve amounts still sum to ₹2315. The result demonstrates what changed: labels moved to a shared descriptive source, while the recorded transactions and their quantities and amounts remained the same. In a larger example with two Pune stores, the City label can appear in both valid store rows, each with its own key. Grouping still works through both keys.

Choose where the field belongs by its meaning

It helps to ask if a value describes an order or the entity it refers to. ProductID lives in Orders as a reference. Category belongs in Products for grouping in this example. The amount a customer actually paid belongs to the fact, because it describes this sale. A current catalog price can be a useful Products attribute, but it cannot reconstruct historical orders unless the recorded price applied exactly and no discounts, fees or other rules intervened. Store and product attributes may legitimately change on their own schedule.

OrderID can still be used as a report filter if the analyst is tracing a specific order. It does not need a separate dimension merely because it can filter. A product price can be numeric in a dimension without being something you sum across the catalog. A useful modeling rule is to decide what the field describes and define how the report should aggregate it. Rules like “numbers always go in facts” and “everything you filter belongs in a dimension” work poorly for these examples.

Check the actual intended report grain when adding a new field. The source can have one row per day and store, one row per order, or one row per order line. Dates and store keys can repeat at any of these grains. Repetition by itself is not an error. Read the same fields against the data contract. In the twelve-row sample each order purchases a single product type and Qty can exceed one. A broader dataset may require line items or an order header plus line facts. Model the actual retained observations rather than forcing one grain onto every table.

Keep historical classifications and amounts consistent

Compare recorded sale prices with a changed catalog

In this fictional exercise the recorded amount equals Qty times the original price from Products. P01 sells for ₹32 and supplies three orders, with quantities 4, 6 and 5. Their original dairy amount is ₹480 for 15 units. Imagine its current catalog price changes to ₹40 after November. If you recompute all historical dairy amounts by using that current price, you get ₹600. The overall model sum would rise falsely from ₹2315 to ₹2435, despite no change to the sales facts. Keep the approved transaction amount or the line price at the sale time when the question is historical sales.

A forecasting workbook may use the current price for a hypothetical scenario. That is a new analytical measure. Label it as scenario sales and compare it with recorded sales so a reader knows what changed. The correct response to an updated Products field depends on the business purpose. Updating a description is different from recasting the actual bill. Keep historical facts separate and write the expected total before changing any approved catalog values on a test copy.

Decide whether a descriptive change applies to past orders

Suppose the same Pune store switches its assigned operating zone from West to Central on November 1 in a separate history example. The ordinary original Stores table has one current row per store. Changing its Zone to Central makes all five linked Pune orders follow the latest label, because the relationship matches by StoreID. The original Pune October subtotal is ₹540 and November is ₹400. With current classification all ₹940 can appear under Central, even though the location’s past zone differed.

If the business asks for each order's zone at the time it was placed, the input needs a trusted history. A versioned dimension can assign one unique row key for the October version and a different key for the November version. The facts must reference the version valid on each fact date. Then the tracked October ₹540 remains under West and November ₹400 goes to Central. Repeating the same business StoreID twice in the one-side lookup without new version keys would fail the requirement. A practical report may source preserved history from an approved upstream table instead of attempting to infer it from the current workbook.

Read Microsoft’s star schema guidance for the general historical modeling pattern. Its Power BI examples cover slowly changing dimensions. This lesson uses those general design ideas, while relationship creation and report authoring are the documented Excel workflows. Decide when a current label is acceptable, such as fixing a spelling error, and when a past grouping must stay versioned. A short policy beside the source makes it clear which type of question each version answers.

Keep monthly targets in a separate fact table

Consider a new, fictional Planning table for Pune. It has one row per store and month. October target is ₹500, and November target is ₹450. Actual Orders includes three Pune purchases in October and two in November. If you join and expand the monthly target onto every corresponding order row, the same October target repeats three times and the November target repeats twice. A sum of the expanded target field becomes ₹2400. The approved planned amount is only ₹950, so the repeated values misstate the comparison.

Pune has targets 500 in October and 450 in November, or 950 correct. Copying October target onto three orders and November target onto two orders gives a wrong sum of 2400.
Keep observations at their approved grain. Repeating a monthly amount on order rows changes what that amount counts.

To compare against targets, use approved common dimensions. The Stores table can supply a unique StoreID filter to both Orders and Planning. An explicitly prepared Month dimension can supply one unique month key that relates to each table at its respective grain. Populate each fact's matching month key from an approved month start or other year-aware key. Report at the shared month and store scope. Avoid a direct join between two fact columns that both contain repeats. A daily date selection or a product category may only have a meaningful path to the sales facts. A monthly store target needs its own allocation rule before it can be compared by day or product.

Independent actual versus monthly target test for Pune.
MonthApproved Orders rowsActual salesTargetActual minus target
October354050040
November2400450−50
Both months5940950−10

A fact table can be summarized without losing its purpose. Monthly Targets stores the approved planning value once per store-month. Orders records each individual event. A later model can add monthly actuals as another prepared fact only when its use and distinct grain are clearly documented. Do not append a target row into the Orders Amount column as an extra sale. Report actual and target from their own accepted columns and compare them only where the selected filters make sense for both.

Compare two reporting grains with a shared scope

  1. Identify Orders grain

    There are five Pune purchases in October and November combined. Recorded amounts sum to ₹940.

  2. Identify Plan grain

    Two Pune plan rows record monthly targets. ₹500 and ₹450 sum to ₹950.

  3. Filter both by approved store and month

    Shared lookup fields select the comparable population. Each fact keeps its own row structure.

  4. Compare amounts once per grain

    Across both months the actual minus target result is −₹10. Repeating targets on purchases gives the wrong planning amount.

Build and audit the design before adding more measures

Lab 1. Reconcile the flat view with the model

  1. Open a copy of the original three-table workbook and verify twelve Orders. List the expected field and grain for each input.
  2. Draw the three spokes from Stores, Products and the intended Calendar to the Orders table. Label their one-side keys and corresponding fact fields. If Calendar is not installed yet, keep it on your design and complete it in the next lesson.
  3. In the existing model verify Stores City filters the Orders Amount to ₹940 for Pune and the all-city sum is ₹2315. Count the five original Pune records.
  4. Check P01 has three Orders rows with 15 units, totaling ₹480. On a practice copy update its catalog price only, keeping the recorded facts intact. Verify that recorded Dairy and all-Order sales remain unchanged.
  5. Explain which values were repeated in a flat worksheet and which remain separate in the model. Retain the clean original source values.

Lab 2. Test why two facts need common dimensions

  1. Write a small Planning table with Pune plus the two approved month-start values and targets ₹500 and ₹450.
  2. Using the original order data, list Pune’s three October and two November facts. Reconcile their amounts to ₹540 and ₹400 respectively.
  3. In a scratch analysis, calculate the incorrect result of writing each monthly target beside every purchase. Verify ₹2400 rather than ₹950.
  4. Draw a revised design with Stores and Month relating to both facts through approved one-column keys. Check City and Month together produce separate actual and target contributions.
  5. Calculate differences by month and combined. Explain why daily or product filters cannot be assigned to the monthly store target without another business rule.

The second lab can be verified on paper before you define a larger workbook model. If you implement the optional extension in a supported Excel authoring client, check the actual Month table uniqueness and both fact relationships. A diagram can show a model that loads. Match its amounts to the original records before considering it finished. Keep the optional Planning table outside the core twelve-order model used in the next lesson.

Test what will aggregate correctly at each grain

Use the field’s definition to choose the operation

At the original order grain, Amount can generally be summed across the approved nonoverlapping observations. Qty can also be summed when the question concerns total recorded units in this particular fixture. A ratio such as sales per unit should be recalculated at the report scope. October's 18 units give ₹1005 divided by 18, about ₹55.83. November's 19 units give ₹1310 divided by 19, about ₹68.95. Both months together represent 37 units and ₹2315, or ₹62.57 per unit. The combined calculation uses total amount divided by total units.

A different calculation can give every purchase its own price ratio and average across purchases. In this fixture, the average of the twelve per-order prices is about ₹72.58. A six-unit purchase of milk at ₹32 and a one-unit purchase of grapes at ₹90 contribute equally to the latter average. They contribute different weights to the actual unit-weighted ratio. Different definitions can be useful in different reports. Name your measure so someone can tell whether its denominator is units, orders or something else.

Price and quantity controls for the original fact table.
PeriodOriginal ordersUnitsRecorded amountSales per unit
October618100555.83
November619131068.95
Both months1237231562.57

A beginner report often assumes every numeric field is additive. An inventory snapshot provides a counterexample. Suppose a fictional stock table contains a count of ten unopened cartons for one store on November 29 and twelve on November 30. The two rows represent separate points in time. Adding them to make twenty-two does not describe physical November-ending stock. Depending on the task, use the latest approved reading or a documented daily average. A number’s data type does not establish the aggregation it can support.

This is why a written grain matters even when two models contain the same column names: a row labeled Qty in Orders means units sold on a purchase, while Qty in Inventory might mean a count reviewed at one instant. In a decision meeting, translate “sum of quantity” into its observation and unit before combining measures. Make sure the group or date selection uses a dimension suitable for that measure.

Compare line-level and order-level inputs before merging

Consider a separate fictional order H1 with a Dairy item worth ₹60 and a Snacks item worth ₹40. A Lines table has two rows and a total of ₹100. The Header table has one row for H1 with approved order amount ₹100. If you merge the full header onto both lines, the header amount appears twice. Summing the order amount column now gives ₹200, although the line-level total remains ₹100. The correct answer for distinct orders is one, and the correct line count is two.

The repeated order ID may be valid in the line table. Choosing only the first fact row would lose one item and ₹40 from the approved sales. Counting distinct orders in the merged data would still return one, while the repeated header amount would still sum to ₹200. Keep the amount at its proper level. Use the line amounts in a line-level sales model, or retain the header facts independently if your question concerns order-level fields. When filtering by category, check whether a whole billed order amount can legitimately be attributed to only one of several purchased categories.

Try explaining this on paper as a message to a teammate. “The total doubled because the same approved header was attached to two separate items.” That evidence gives a concrete repair path. “The PivotTable is wrong” does not. Describe whether you will report line sales, count unique orders, or show approved whole-order amounts at header scope. If one measure needs shared product and date context, verify that it still answers the intended question when those filters are applied.

Choose a primary key that preserves the lookup series over time

Draw the original Stores table. The key on every row has a single value, and City and Platform describe that store. You can add a new genuinely distinct store in Pune with its own StoreID and the same City label. It can coexist safely with the current Pune store. A City filter would keep both approved Stores rows, but no order should match twice simply because the two stores share a city name. This relationship uses StoreID, not City. Reusable labels and unique IDs are two separate notions.

Now suppose the business wants the same physical store’s approved name as of each sale. With a versioned dimension, two different lookup rows may share the stable business ID but have different unique version keys. Keep effective dates in the source history and resolve the fact to the correct unique version upstream. A single relationship to just the business ID would have a duplicated lookup key. A date-and-ID pair can describe the business logic; for use in Excel Data Model, prepare a single validated version key. Do not make a version dimension by copying old labels into a live workbook without reliable approval and effective dates.

Check the model’s current versus historical role with a concrete difference. In the zone-change exercise the current model can assign all ₹940 to Central. A history-preserving report splits ₹540 West and ₹400 Central. Both add to the same underlying sales for the one Pune store. Choose the version by the nature of the question and communicate it as part of the report heading. An analyst reviewing expected numbers needs to know what was approved as a current attribute and what was preserved at the event date.

Decide when a flat table is the practical output

A flat export can be useful for a recipient who needs every approved order plus its descriptive product and store labels. Prepare it from verified facts and lookup keys, and compare the number of output rows after selecting fields or expanding related records. The four-row flat example on this page confirms exactly which labels came from the two dimension records. If a merge unexpectedly creates extra rows, inspect how many lookup records matched each source ID before distributing it. A tidy exported row does not guarantee that the number of distinct observed orders stayed the same.

In contrast, the workbook model that feeds several PivotTables can preserve its one fact table and the approved dimensions. It can build a flat output for a specific use as a separate view if needed. There is no reason to append the export back into Orders and count the same facts a second time. Give the two artifacts clear roles: one contains the analysis inputs and relationships, and one is a review or delivery view. Different sizes and storage behavior depend on the actual model and workbook. Use volume and report tests before making broad guarantees about speed.

Trace group results through a dimension record and then the fact amounts

In an Excel client that supports model authoring, use a PivotTable with Stores Platform in Rows and Sum of Orders Amount in Values. FreshGo keeps the approved Pune and Nashik Stores rows, contributing ₹940 plus ₹670, or ₹1610. MarketRush keeps Nagpur and Solapur, contributing ₹355 plus ₹350, or ₹705. This grouping uses the same StoreID relationship as the city report. You did not need a separate row-specific platform lookup or a second relationship using a platform text field.

Add Products Category to a second report and filter all examples to the clean original. Dairy contributes ₹480. If you specify both FreshGo and Dairy, the two Pune milk orders contribute ₹320. The third dairy fact of ₹160 uses the Nagpur store in MarketRush. Compare the relevant dimension labels to the exact order IDs before concluding that any imported product or store label was lost. A new report field can reuse an approved edge only if it comes from the intended model table and its population built that way.

Use a similar logic for period, but verify the accepted calendar coverage separately from event sparsity. October 1 and November 30 are within the proposed Calendar even when no order occurred in the sample on those dates. A date dimension lets a report describe such days consistently. Some PivotTable settings omit categories with no data, and some measures can return blank for empty selections. An absent label on a visual is not evidence by itself of a missing calendar row or a failed relationship.

Document the model in business terms so it can be reviewed

Give the finished diagram a small dictionary. In Orders, define which approvals are needed for one row, how prices were recorded, which identifiers connect to dimensions, and which date role is used. In Stores and Products, name the unique keys and whether labels are current or historic. In Calendar, state the complete period you intend to cover and which facts relate to it. Beside every measure, state its units and denominator if applicable. This dictionary is actionable evidence for a person who inherits the workbook.

Before saving the practice copy, compare the exact baseline checks across several views. Confirm twelve facts worth ₹2315, five Pune records worth ₹940, two months whose sums reconcile, and relevant category and platform slices. If a separate Planning table is present, verify twelve original Orders still exist because adding a target should not create a sale. Recheck that all target rows share the approved Month and Store keys and no report claims a per-day target from a monthly row. Document the added data and relationship roles as deliberately as the original model shape.

Decide how to test a refresh next time. A model where store labels are corrected can produce a new city split while its amount and fact count stay the same. A model where a purchase is added should change its row count and likely an amount. A change to a current catalog price need not change recorded sales. Write down those expected patterns rather than treating every difference as a problem. A report is easier to trust when a learner can explain which layer or grain produced a change.

Use explicit comparison filters if you implement the two-fact extension

On a separate copy, build Month as one row per approved month start. Include October 1 and November 1 as date values and give each a period label with its year. On the Orders source derive MonthStart from the approved Order Date. On Planning put the matching MonthStart in each target row. Keep Orders at its original daily fact grain; the new key supplies a monthly grouping and does not make each order a monthly event. Load Month and Planning through the eligible model workflow taught earlier.

Connect the unique MonthStart in Month to the matching field in each fact, and the unique StoreID in Stores to the corresponding store key in both. For this separate extension use Month as the shared date dimension for the comparison. Select the store from Stores and the period from Month, rather than using a month column that exists only on one fact. Check the relationship diagram for clear independent paths. Put approved Sales and Target aggregates side by side. They should show the two rows of the acceptance table above for Pune and the combined difference of −₹10.

The practice Planning table has no approved Solapur targets. The actual sales measure can still show ₹350 for Solapur. The target input is absent, so a variance should show an incomplete comparison under this exercise’s policy. An expression that treats missing plan as zero would imply Solapur exceeded an approved zero target by ₹350. That would be an inaccurate inference. Give plans their own coverage check and distinguish no target received from a legitimately approved target of zero. A valid shared relationship does not establish that every fact table covers every store and month.

Similarly, applying a Products Category filter to the model can select Dairy sales without narrowing the plan if Planning has no Product key. If that happens, a direct difference would compare a product-only sales subset with a full store plan. Use a common-scope report, or document an allocation rule that can make a translated product-level target defensible. Clicking a report filter is not evidence that the filter reaches every number on screen. Identify the dimensions each measure is intended to follow.

Verify the report’s approved comparison horizon

The original star diagram has a day-level Calendar spanning exactly 61 days for its two-month practice file. A later workbook covering a full reporting year may need every date in that year, plus earlier ranges for comparison. A standalone two-month target file gives no values for other periods. Carrying a full Calendar does not create new actual or target facts. Record observations and period coverage separately. For the optional comparison, write a short note identifying whether the October and November values describe closed original sample periods or simply the approved sample rows.

Ask somebody reviewing your optional model to show the grain of each fact, one supported shared filter, and one filter that is unsafe for comparing both measures. Reconcile all approved source amounts before drawing conclusions. A star-shaped diagram that looks neat can still leave a monthly target repeated or a Calendar filtering only the actuals. The expected case values supply evidence for how the model behaved, beyond how it was drawn.

To make the independent unit check reproducible, define Total Units as the sum of Orders Qty, and use the ratio of those two approved aggregates in the report. Apply a numeric display format after computing the ratio. Check that the all-order unit count stays 37 after merely switching the displayed dimension. It should change only if the active filters or approved fact inputs change.

Total Sales := SUM(Orders[Amount])
Total Units := SUM(Orders[Qty])
Sales per Unit := DIVIDE([Total Sales], [Total Units])

If you move a displayed City or Category field, check that the report still uses the connected lookup and the same chosen scope.

Explain your model design before drawing another relationship

Quiz

What does fact grain mean in the sample?

One row represents one approved source order. Its date and entity IDs describe when it occurred and which entities it belongs to.

Where should current product category live?

Products is the descriptive dimension with a unique ProductID. Orders can keep just the compatible product key for this report design.

Why can changing catalog price leave actual sales untouched?

Recorded transaction amounts belong to the fact. The current catalog price is a different attribute that may have changed after those sales.

What is the correct combined monthly Pune target?

₹950, from one ₹500 plan and one ₹450 plan. Repeating those amounts on five orders would overstate targets.

What does adding Calendar to the star solve?

It provides one approved date key and useful time labels such as month and year so date choices can filter matching Orders.

Interview questions and answers

What makes a model a star schema?

Its fact table stores events at a defined grain. Descriptive dimensions relate through matching keys, making it possible to group and filter the fact in shared ways.

When would you retain historical versions in a dimension?

When earlier facts must stay classified by the attribute effective when the event occurred. Give each version a unique key and map facts accordingly.

Is a flat worksheet always a poor design?

A flat view can suit a small fixed export or manual audit. A relational model can better support shared filtering and separate update responsibilities. Test the size and report needs.

How would you prevent duplicated targets in a sales report?

Keep targets at their approved monthly store grain and filter both facts with common dimensions. Measure actual and plan independently before comparing them.

What evidence proves the model added no sales during redesign?

Reconcile the same approved twelve fact rows, ₹2315 total and specific city or category numbers before and after building the relationships.

Revision cards

  • Fact grain. A precise description of the observation represented by each row.
  • Dimension key. A unique lookup ID that can describe many related facts.
  • Star. Keep shared descriptive paths clear around the facts the report summarizes.
  • Historical value. Preserve the approved transaction amount and any required point-in-time classification.
  • Shared scope. A month/store target can be compared with sales from that month and store.
  • Reconcile. Check scope, counts and known amounts before and after restructuring.

Revisit the original flat-versus-star illustration, use the Excel Practice Task Hub, or continue to building a calendar dimension.

Microsoft references