24. Power Pivot and the Data Model
Practice and Answer Key: A Two-Month Data Model
Goal of this practice: Build a small Data Model from three tables, relate them, write five measures and read numbers with CUBEVALUE.
या practice चं ध्येय: तीन tables मधून छोटं Data Model बनवा, त्या जोडा, पाच measures लिहा आणि CUBEVALUE ने आकडे वाचा.
इस practice का लक्ष्य: तीन tables से छोटा Data Model बनाएँ, उन्हें जोड़ें, पाँच measures लिखें और CUBEVALUE से आँकड़े पढ़ें.
Suppose Rani tracks three fictional stores in Kolhapur, Sambhaji Nagar and Pune for October and November 2026. All data is fictional practice data. Amount = Qty × Price (add it as a column in Orders before loading).
| StoreID | City | Platform |
|---|---|---|
| S1 | Kolhapur | Blinkit |
| S2 | Sambhaji Nagar | Amazon Now |
| S3 | Pune | Amazon Now |
| ProductID | Product | Category | Price (₹) |
|---|---|---|---|
| K1 | Paneer 200 g | Dairy | 95 |
| K2 | Kanda Poha Mix | Staples | 55 |
| K3 | Alphonso Pulp 850 g | Fruits | 180 |
| OrderID | Date | StoreID | ProductID | CustomerID | Qty |
|---|---|---|---|---|---|
| A-01 | 04-10-2026 | S1 | K1 | C11 | 3 |
| A-02 | 09-10-2026 | S2 | K3 | C12 | 1 |
| A-03 | 15-10-2026 | S3 | K2 | C13 | 4 |
| A-04 | 26-10-2026 | S1 | K3 | C11 | 2 |
| A-05 | 03-11-2026 | S2 | K1 | C14 | 2 |
| A-06 | 12-11-2026 | S3 | K3 | C13 | 2 |
| A-07 | 18-11-2026 | S1 | K2 | C15 | 5 |
| A-08 | 25-11-2026 | S3 | K1 | C12 | 4 |
Exercise (one under the other):
- Type the three tables, make them Excel Tables named Orders, Stores and Products, and add Amount to Orders.
- Load all three into the Data Model and create the two relationships in Diagram View.
- Build a Calendar table for 01-10-2026 to 30-11-2026, relate it and mark it as the date table.
- Create the measures Total Sales, Customers, Amazon Now Sales, Sales LM and MoM %.
- Build a PivotTable from the Data Model: City in Rows, Calendar[Month] in Columns, Total Sales in Values.
- Write a CUBEVALUE for Kolhapur in November.
Expected result (check your numbers):
| Check | Expected |
|---|---|
| Total Sales | ₹2,250 |
| Customers (distinct) | 5 |
| Sales by City (Kolhapur / Sambhaji Nagar / Pune) | ₹920 / ₹370 / ₹960 |
| Amazon Now Sales | ₹1,330 |
| Oct / Nov | ₹1,045 / ₹1,205 |
| MoM % for Nov | 15.3% |
| CUBEVALUE Kolhapur, Nov | ₹275 |
Answer key (open after you try)
Total Sales := SUM(Orders[Amount])
Customers := DISTINCTCOUNT(Orders[CustomerID])
Amazon Now Sales := CALCULATE([Total Sales], Stores[Platform] = "Amazon Now")
Sales LM := CALCULATE([Total Sales], DATEADD(Calendar[Date], -1, MONTH))
MoM % := DIVIDE([Total Sales] - [Sales LM], [Sales LM])
CUBE cell : =CUBEVALUE("ThisWorkbookDataModel","[Measures].[Total Sales]","[Stores].[City].&[Kolhapur]","[Calendar].[Month].&[Nov]")
Common mistakes:
| What you see | Why | Fix |
|---|---|---|
| Every city shows ₹2,250 | Relationship Orders[StoreID] → Stores[StoreID] is missing | Create it in Diagram View and refresh |
| Nov appears before Oct | Month is sorted as text | Home › Sort by Column: Month by Month Number |
| Sales LM is blank for every month | Calendar is not related or not marked as the date table | Relate Orders[Date] to Calendar[Date] and Mark as Date Table |
| Customers by city add up to more than 5 | Not a mistake: a customer bought in two cities | Trust the Grand Total of the distinct count |
Ravindra Bagale's rule: Tables first, relationships second, measures third, visuals last.
Quick recap
- The Data Model holds several Tables plus relationships; Power Pivot is the window to manage it.
- Fact tables hold events and numbers; dimension tables hold names to filter by. Fact in the middle = star schema.
- A marked Calendar table fixes month sorting and makes DATEADD and TOTALYTD work.
- Get Data › From Folder › Only Create Connection + Add to the Data Model combines monthly files into one fact table.
- Measures (SUM, COUNTROWS, DISTINCTCOUNT, CALCULATE, DIVIDE) work in every PivotTable layout.
- Insert › PivotTable › From Data Model; Convert to Formulas gives CUBEVALUE cells for fixed reports.
- Move to Power BI for sharing, scheduled refresh and row-level security; the model imports in one step.