@luquimbo/bi-superpowers 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +8 -0
- package/.mcp.json +25 -0
- package/AGENTS.md +244 -0
- package/CHANGELOG.md +265 -0
- package/LICENSE +21 -0
- package/README.md +211 -0
- package/bin/build-plugin.js +30 -0
- package/bin/cli.js +1064 -0
- package/bin/commands/add.js +533 -0
- package/bin/commands/add.test.js +77 -0
- package/bin/commands/build-desktop.js +166 -0
- package/bin/commands/changelog.js +443 -0
- package/bin/commands/diff.js +325 -0
- package/bin/commands/lint.js +419 -0
- package/bin/commands/lint.test.js +103 -0
- package/bin/commands/mcp-setup.js +246 -0
- package/bin/commands/pull.js +287 -0
- package/bin/commands/pull.test.js +36 -0
- package/bin/commands/push.js +231 -0
- package/bin/commands/push.test.js +14 -0
- package/bin/commands/search.js +344 -0
- package/bin/commands/search.test.js +115 -0
- package/bin/commands/setup.js +545 -0
- package/bin/commands/setup.test.js +46 -0
- package/bin/commands/sync-profile.js +405 -0
- package/bin/commands/sync-profile.test.js +14 -0
- package/bin/commands/sync-source.js +418 -0
- package/bin/commands/sync-source.test.js +14 -0
- package/bin/commands/watch.js +206 -0
- package/bin/lib/generators/claude-plugin.js +266 -0
- package/bin/lib/generators/claude-plugin.test.js +110 -0
- package/bin/lib/generators/index.js +116 -0
- package/bin/lib/generators/shared.js +282 -0
- package/bin/lib/licensing/index.js +35 -0
- package/bin/lib/licensing/storage.js +364 -0
- package/bin/lib/licensing/storage.test.js +55 -0
- package/bin/lib/licensing/validator.js +213 -0
- package/bin/lib/licensing/validator.test.js +137 -0
- package/bin/lib/microsoft-mcp.js +176 -0
- package/bin/lib/microsoft-mcp.test.js +106 -0
- package/bin/lib/skills.js +84 -0
- package/bin/mcp/powerbi-modeling-launcher.js +38 -0
- package/bin/postinstall.js +44 -0
- package/bin/utils/errors.js +159 -0
- package/bin/utils/git.js +298 -0
- package/bin/utils/logger.js +142 -0
- package/bin/utils/mcp-detect.js +274 -0
- package/bin/utils/mcp-detect.test.js +105 -0
- package/bin/utils/pbix.js +305 -0
- package/bin/utils/pbix.test.js +37 -0
- package/bin/utils/profiles.js +312 -0
- package/bin/utils/projects.js +168 -0
- package/bin/utils/readline.js +206 -0
- package/bin/utils/readline.test.js +47 -0
- package/bin/utils/tui.js +314 -0
- package/bin/utils/tui.test.js +127 -0
- package/commands/contributions.md +265 -0
- package/commands/data-model-design.md +468 -0
- package/commands/dax-doctor.md +248 -0
- package/commands/fabric-scripts.md +452 -0
- package/commands/migration-assistant.md +290 -0
- package/commands/model-documenter.md +242 -0
- package/commands/pbi-connect.md +239 -0
- package/commands/project-kickoff.md +905 -0
- package/commands/report-layout.md +296 -0
- package/commands/rls-design.md +533 -0
- package/commands/theme-tweaker.md +624 -0
- package/config.example.json +23 -0
- package/config.json +23 -0
- package/desktop-extension/manifest.json +37 -0
- package/desktop-extension/package.json +10 -0
- package/desktop-extension/server.js +95 -0
- package/docs/openrouter-free-models.md +92 -0
- package/library/examples/README.md +151 -0
- package/library/examples/finance-reporting/README.md +351 -0
- package/library/examples/finance-reporting/data-model.md +267 -0
- package/library/examples/finance-reporting/measures.dax +557 -0
- package/library/examples/hr-analytics/README.md +371 -0
- package/library/examples/hr-analytics/data-model.md +315 -0
- package/library/examples/hr-analytics/measures.dax +460 -0
- package/library/examples/marketing-analytics/README.md +37 -0
- package/library/examples/marketing-analytics/data-model.md +62 -0
- package/library/examples/marketing-analytics/measures.dax +110 -0
- package/library/examples/retail-analytics/README.md +439 -0
- package/library/examples/retail-analytics/data-model.md +288 -0
- package/library/examples/retail-analytics/measures.dax +481 -0
- package/library/examples/supply-chain/README.md +37 -0
- package/library/examples/supply-chain/data-model.md +69 -0
- package/library/examples/supply-chain/measures.dax +77 -0
- package/library/examples/udf-library/README.md +228 -0
- package/library/examples/udf-library/functions.dax +571 -0
- package/library/snippets/dax/README.md +292 -0
- package/library/snippets/dax/business-domains.md +576 -0
- package/library/snippets/dax/calculate-patterns.md +276 -0
- package/library/snippets/dax/calculation-groups.md +489 -0
- package/library/snippets/dax/error-handling.md +495 -0
- package/library/snippets/dax/iterators-and-aggregations.md +474 -0
- package/library/snippets/dax/kpis-and-metrics.md +293 -0
- package/library/snippets/dax/rankings-and-topn.md +235 -0
- package/library/snippets/dax/security-patterns.md +413 -0
- package/library/snippets/dax/text-and-formatting.md +316 -0
- package/library/snippets/dax/time-intelligence.md +196 -0
- package/library/snippets/dax/user-defined-functions.md +477 -0
- package/library/snippets/dax/virtual-tables.md +546 -0
- package/library/snippets/excel-formulas/README.md +84 -0
- package/library/snippets/excel-formulas/aggregations.md +330 -0
- package/library/snippets/excel-formulas/dates-and-times.md +361 -0
- package/library/snippets/excel-formulas/dynamic-arrays.md +314 -0
- package/library/snippets/excel-formulas/lookups.md +169 -0
- package/library/snippets/excel-formulas/text-functions.md +363 -0
- package/library/snippets/governance/naming-conventions.md +97 -0
- package/library/snippets/governance/review-checklists.md +107 -0
- package/library/snippets/power-query/README.md +389 -0
- package/library/snippets/power-query/api-integration.md +707 -0
- package/library/snippets/power-query/connections.md +434 -0
- package/library/snippets/power-query/data-cleaning.md +298 -0
- package/library/snippets/power-query/error-handling.md +526 -0
- package/library/snippets/power-query/parameters.md +350 -0
- package/library/snippets/power-query/performance.md +506 -0
- package/library/snippets/power-query/transformations.md +330 -0
- package/library/snippets/report-design/accessibility.md +78 -0
- package/library/snippets/report-design/chart-selection.md +54 -0
- package/library/snippets/report-design/layout-patterns.md +87 -0
- package/library/templates/data-models/README.md +93 -0
- package/library/templates/data-models/finance-model.md +627 -0
- package/library/templates/data-models/retail-star-schema.md +473 -0
- package/library/templates/excel/README.md +83 -0
- package/library/templates/excel/budget-tracker.md +432 -0
- package/library/templates/excel/data-entry-form.md +533 -0
- package/library/templates/power-bi/README.md +72 -0
- package/library/templates/power-bi/finance-report.md +449 -0
- package/library/templates/power-bi/kpi-scorecard.md +461 -0
- package/library/templates/power-bi/sales-dashboard.md +281 -0
- package/library/themes/excel/README.md +436 -0
- package/library/themes/power-bi/README.md +271 -0
- package/library/themes/power-bi/accessible.json +307 -0
- package/library/themes/power-bi/bi-superpowers-default.json +858 -0
- package/library/themes/power-bi/corporate-blue.json +291 -0
- package/library/themes/power-bi/dark-mode.json +291 -0
- package/library/themes/power-bi/minimal.json +292 -0
- package/library/themes/power-bi/print-friendly.json +309 -0
- package/package.json +93 -0
- package/skills/contributions/SKILL.md +267 -0
- package/skills/data-model-design/SKILL.md +470 -0
- package/skills/data-modeling/SKILL.md +254 -0
- package/skills/data-quality/SKILL.md +664 -0
- package/skills/dax/SKILL.md +708 -0
- package/skills/dax-doctor/SKILL.md +250 -0
- package/skills/dax-udf/SKILL.md +489 -0
- package/skills/deployment/SKILL.md +320 -0
- package/skills/excel-formulas/SKILL.md +463 -0
- package/skills/fabric-scripts/SKILL.md +454 -0
- package/skills/fast-standard/SKILL.md +509 -0
- package/skills/governance/SKILL.md +205 -0
- package/skills/migration-assistant/SKILL.md +292 -0
- package/skills/model-documenter/SKILL.md +244 -0
- package/skills/pbi-connect/SKILL.md +241 -0
- package/skills/power-query/SKILL.md +406 -0
- package/skills/project-kickoff/SKILL.md +907 -0
- package/skills/query-performance/SKILL.md +480 -0
- package/skills/report-design/SKILL.md +207 -0
- package/skills/report-layout/SKILL.md +298 -0
- package/skills/rls-design/SKILL.md +535 -0
- package/skills/semantic-model/SKILL.md +237 -0
- package/skills/testing-validation/SKILL.md +643 -0
- package/skills/theme-tweaker/SKILL.md +626 -0
- package/src/content/base.md +237 -0
- package/src/content/mcp-requirements.json +69 -0
- package/src/content/routing.md +203 -0
- package/src/content/skills/contributions.md +259 -0
- package/src/content/skills/data-model-design.md +462 -0
- package/src/content/skills/data-modeling.md +246 -0
- package/src/content/skills/data-quality.md +656 -0
- package/src/content/skills/dax-doctor.md +242 -0
- package/src/content/skills/dax-udf.md +481 -0
- package/src/content/skills/dax.md +700 -0
- package/src/content/skills/deployment.md +312 -0
- package/src/content/skills/excel-formulas.md +455 -0
- package/src/content/skills/fabric-scripts.md +446 -0
- package/src/content/skills/fast-standard.md +501 -0
- package/src/content/skills/governance.md +197 -0
- package/src/content/skills/migration-assistant.md +284 -0
- package/src/content/skills/model-documenter.md +236 -0
- package/src/content/skills/pbi-connect.md +233 -0
- package/src/content/skills/power-query.md +398 -0
- package/src/content/skills/project-kickoff.md +899 -0
- package/src/content/skills/query-performance.md +472 -0
- package/src/content/skills/report-design.md +199 -0
- package/src/content/skills/report-layout.md +290 -0
- package/src/content/skills/rls-design.md +527 -0
- package/src/content/skills/semantic-model.md +229 -0
- package/src/content/skills/testing-validation.md +635 -0
- package/src/content/skills/theme-tweaker.md +618 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
# Retail Star Schema Model
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
A comprehensive star schema design for retail analytics covering sales transactions, inventory management, customer analysis, and store performance. Optimized for Power BI semantic models with best practices for relationships, hierarchies, and calculations.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Business Context
|
|
10
|
+
|
|
11
|
+
### Key Business Questions
|
|
12
|
+
|
|
13
|
+
1. **Sales Analysis**
|
|
14
|
+
- What are total sales by product category, store, and time period?
|
|
15
|
+
- How do promotions impact sales?
|
|
16
|
+
- What is the sales trend over time?
|
|
17
|
+
|
|
18
|
+
2. **Customer Behavior**
|
|
19
|
+
- Who are the most valuable customers?
|
|
20
|
+
- What products are frequently purchased together?
|
|
21
|
+
- How does customer segmentation affect revenue?
|
|
22
|
+
|
|
23
|
+
3. **Inventory Management**
|
|
24
|
+
- What is the current stock level by product and store?
|
|
25
|
+
- Which products are at risk of stockout?
|
|
26
|
+
- What is the inventory turnover rate?
|
|
27
|
+
|
|
28
|
+
4. **Store Performance**
|
|
29
|
+
- How do stores compare in revenue and profitability?
|
|
30
|
+
- What is sales per square foot by store?
|
|
31
|
+
- How does store location affect performance?
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Schema Diagram
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
┌─────────────┐
|
|
39
|
+
│ DimDate │
|
|
40
|
+
│─────────────│
|
|
41
|
+
│ DateKey (PK)│
|
|
42
|
+
│ Date │
|
|
43
|
+
│ Year │
|
|
44
|
+
│ Quarter │
|
|
45
|
+
│ Month │
|
|
46
|
+
│ Week │
|
|
47
|
+
│ DayOfWeek │
|
|
48
|
+
│ IsWeekend │
|
|
49
|
+
│ IsHoliday │
|
|
50
|
+
│ FiscalYear │
|
|
51
|
+
└──────┬──────┘
|
|
52
|
+
│
|
|
53
|
+
│ 1:M
|
|
54
|
+
│
|
|
55
|
+
┌─────────────┐ ┌──────┴──────┐ ┌─────────────┐
|
|
56
|
+
│ DimProduct │ │ FactSales │ │ DimCustomer │
|
|
57
|
+
│─────────────│ │─────────────│ │─────────────│
|
|
58
|
+
│ProductKey PK│────>│SalesKey (PK)│<────│CustomerKey │
|
|
59
|
+
│ ProductID │ M:1 │ DateKey (FK)│ 1:M │ CustomerID │
|
|
60
|
+
│ ProductName │ │ProductKey FK│ │ FirstName │
|
|
61
|
+
│ Category │ │CustomerKey │ │ LastName │
|
|
62
|
+
│ SubCategory │ │ StoreKey FK │ │ Email │
|
|
63
|
+
│ Brand │ │PromoKey FK │ │ Segment │
|
|
64
|
+
│ UnitCost │ │ Quantity │ │ JoinDate │
|
|
65
|
+
│ UnitPrice │ │ UnitPrice │ │ City │
|
|
66
|
+
│ SKU │ │ TotalAmount │ │ State │
|
|
67
|
+
│ IsActive │ │ Discount │ │ Country │
|
|
68
|
+
└─────────────┘ │ Cost │ └─────────────┘
|
|
69
|
+
└──────┬──────┘
|
|
70
|
+
│
|
|
71
|
+
┌────────────────┼────────────────┐
|
|
72
|
+
│ │ │
|
|
73
|
+
│ M:1 │ M:1 │ M:1
|
|
74
|
+
▼ ▼ ▼
|
|
75
|
+
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
76
|
+
│ DimStore │ │DimPromotion │ │ DimEmployee │
|
|
77
|
+
│─────────────│ │─────────────│ │─────────────│
|
|
78
|
+
│StoreKey (PK)│ │PromoKey (PK)│ │EmployeeKey │
|
|
79
|
+
│ StoreID │ │ PromoID │ │ EmployeeID │
|
|
80
|
+
│ StoreName │ │ PromoName │ │ Name │
|
|
81
|
+
│ StoreType │ │ PromoType │ │ Title │
|
|
82
|
+
│ OpenDate │ │ StartDate │ │ HireDate │
|
|
83
|
+
│ SquareFeet │ │ EndDate │ │ ManagerKey │
|
|
84
|
+
│ City │ │ DiscountPct │ │ Department │
|
|
85
|
+
│ State │ │ MinPurchase │ └─────────────┘
|
|
86
|
+
│ Region │ └─────────────┘
|
|
87
|
+
│ Manager │
|
|
88
|
+
└─────────────┘
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Dimension Tables
|
|
94
|
+
|
|
95
|
+
### DimDate (Date Dimension)
|
|
96
|
+
|
|
97
|
+
**Purpose:** Standard date dimension for time intelligence
|
|
98
|
+
|
|
99
|
+
| Column | Data Type | Description | Sample Values |
|
|
100
|
+
|--------|-----------|-------------|---------------|
|
|
101
|
+
| DateKey | INT | Surrogate key (YYYYMMDD) | 20240115 |
|
|
102
|
+
| Date | DATE | Full date | 2024-01-15 |
|
|
103
|
+
| Year | INT | Calendar year | 2024 |
|
|
104
|
+
| Quarter | INT | Quarter number (1-4) | 1 |
|
|
105
|
+
| QuarterName | VARCHAR(2) | Quarter label | Q1 |
|
|
106
|
+
| Month | INT | Month number (1-12) | 1 |
|
|
107
|
+
| MonthName | VARCHAR(20) | Month name | January |
|
|
108
|
+
| MonthShort | VARCHAR(3) | Abbreviated month | Jan |
|
|
109
|
+
| Week | INT | Week of year | 3 |
|
|
110
|
+
| DayOfMonth | INT | Day of month | 15 |
|
|
111
|
+
| DayOfWeek | INT | Day of week (1-7) | 2 |
|
|
112
|
+
| DayName | VARCHAR(10) | Day name | Monday |
|
|
113
|
+
| IsWeekend | BIT | Weekend flag | 0 |
|
|
114
|
+
| IsHoliday | BIT | Holiday flag | 0 |
|
|
115
|
+
| HolidayName | VARCHAR(50) | Holiday name | NULL |
|
|
116
|
+
| FiscalYear | INT | Fiscal year | 2024 |
|
|
117
|
+
| FiscalQuarter | INT | Fiscal quarter | 3 |
|
|
118
|
+
| FiscalMonth | INT | Fiscal month | 7 |
|
|
119
|
+
| YearMonth | INT | Year-month key | 202401 |
|
|
120
|
+
|
|
121
|
+
**Hierarchies:**
|
|
122
|
+
- Calendar: Year > Quarter > Month > Date
|
|
123
|
+
- Fiscal: FiscalYear > FiscalQuarter > FiscalMonth
|
|
124
|
+
- Weekly: Year > Week > Date
|
|
125
|
+
|
|
126
|
+
### DimProduct (Product Dimension)
|
|
127
|
+
|
|
128
|
+
**Purpose:** Product master with category hierarchy
|
|
129
|
+
|
|
130
|
+
| Column | Data Type | Description | Sample Values |
|
|
131
|
+
|--------|-----------|-------------|---------------|
|
|
132
|
+
| ProductKey | INT | Surrogate key | 1001 |
|
|
133
|
+
| ProductID | VARCHAR(20) | Business key | PROD-001 |
|
|
134
|
+
| ProductName | VARCHAR(100) | Product name | Wireless Mouse |
|
|
135
|
+
| SKU | VARCHAR(50) | Stock keeping unit | WM-BLK-001 |
|
|
136
|
+
| Category | VARCHAR(50) | Product category | Electronics |
|
|
137
|
+
| SubCategory | VARCHAR(50) | Product subcategory | Accessories |
|
|
138
|
+
| Brand | VARCHAR(50) | Brand name | TechBrand |
|
|
139
|
+
| UnitCost | DECIMAL(10,2) | Cost per unit | 15.00 |
|
|
140
|
+
| UnitPrice | DECIMAL(10,2) | List price | 29.99 |
|
|
141
|
+
| Weight | DECIMAL(8,2) | Weight in lbs | 0.25 |
|
|
142
|
+
| Color | VARCHAR(30) | Product color | Black |
|
|
143
|
+
| Size | VARCHAR(20) | Product size | Standard |
|
|
144
|
+
| IsActive | BIT | Currently sold | 1 |
|
|
145
|
+
| IntroDate | DATE | Introduction date | 2023-01-01 |
|
|
146
|
+
| DiscontinueDate | DATE | Discontinue date | NULL |
|
|
147
|
+
|
|
148
|
+
**Hierarchies:**
|
|
149
|
+
- Product: Category > SubCategory > Brand > Product
|
|
150
|
+
|
|
151
|
+
### DimCustomer (Customer Dimension)
|
|
152
|
+
|
|
153
|
+
**Purpose:** Customer master with demographics
|
|
154
|
+
|
|
155
|
+
| Column | Data Type | Description | Sample Values |
|
|
156
|
+
|--------|-----------|-------------|---------------|
|
|
157
|
+
| CustomerKey | INT | Surrogate key | 5001 |
|
|
158
|
+
| CustomerID | VARCHAR(20) | Business key | CUST-12345 |
|
|
159
|
+
| FirstName | VARCHAR(50) | First name | John |
|
|
160
|
+
| LastName | VARCHAR(50) | Last name | Smith |
|
|
161
|
+
| FullName | VARCHAR(100) | Full name | John Smith |
|
|
162
|
+
| Email | VARCHAR(100) | Email address | john@email.com |
|
|
163
|
+
| Phone | VARCHAR(20) | Phone number | 555-123-4567 |
|
|
164
|
+
| Gender | VARCHAR(10) | Gender | Male |
|
|
165
|
+
| BirthDate | DATE | Birth date | 1985-03-15 |
|
|
166
|
+
| JoinDate | DATE | Customer since | 2020-06-01 |
|
|
167
|
+
| Segment | VARCHAR(30) | Customer segment | Gold |
|
|
168
|
+
| AddressLine1 | VARCHAR(100) | Street address | 123 Main St |
|
|
169
|
+
| City | VARCHAR(50) | City | Seattle |
|
|
170
|
+
| State | VARCHAR(50) | State/Province | WA |
|
|
171
|
+
| PostalCode | VARCHAR(20) | Postal code | 98101 |
|
|
172
|
+
| Country | VARCHAR(50) | Country | USA |
|
|
173
|
+
| IsActive | BIT | Active customer | 1 |
|
|
174
|
+
|
|
175
|
+
**Hierarchies:**
|
|
176
|
+
- Geography: Country > State > City
|
|
177
|
+
- Segment: Segment > Customer
|
|
178
|
+
|
|
179
|
+
### DimStore (Store Dimension)
|
|
180
|
+
|
|
181
|
+
**Purpose:** Store/location master
|
|
182
|
+
|
|
183
|
+
| Column | Data Type | Description | Sample Values |
|
|
184
|
+
|--------|-----------|-------------|---------------|
|
|
185
|
+
| StoreKey | INT | Surrogate key | 101 |
|
|
186
|
+
| StoreID | VARCHAR(20) | Business key | STORE-001 |
|
|
187
|
+
| StoreName | VARCHAR(100) | Store name | Downtown Seattle |
|
|
188
|
+
| StoreType | VARCHAR(30) | Store type | Flagship |
|
|
189
|
+
| OpenDate | DATE | Opening date | 2018-05-15 |
|
|
190
|
+
| CloseDate | DATE | Closing date | NULL |
|
|
191
|
+
| SquareFeet | INT | Store size | 25000 |
|
|
192
|
+
| AddressLine1 | VARCHAR(100) | Street address | 500 Pine St |
|
|
193
|
+
| City | VARCHAR(50) | City | Seattle |
|
|
194
|
+
| State | VARCHAR(50) | State | WA |
|
|
195
|
+
| PostalCode | VARCHAR(20) | Postal code | 98101 |
|
|
196
|
+
| Country | VARCHAR(50) | Country | USA |
|
|
197
|
+
| Region | VARCHAR(30) | Sales region | Pacific Northwest |
|
|
198
|
+
| District | VARCHAR(30) | District | Seattle Metro |
|
|
199
|
+
| ManagerName | VARCHAR(100) | Store manager | Jane Doe |
|
|
200
|
+
| Phone | VARCHAR(20) | Phone | 555-234-5678 |
|
|
201
|
+
| IsActive | BIT | Currently open | 1 |
|
|
202
|
+
|
|
203
|
+
**Hierarchies:**
|
|
204
|
+
- Geography: Region > District > Store
|
|
205
|
+
- Store Type: StoreType > Store
|
|
206
|
+
|
|
207
|
+
### DimPromotion (Promotion Dimension)
|
|
208
|
+
|
|
209
|
+
**Purpose:** Promotional campaigns and discounts
|
|
210
|
+
|
|
211
|
+
| Column | Data Type | Description | Sample Values |
|
|
212
|
+
|--------|-----------|-------------|---------------|
|
|
213
|
+
| PromoKey | INT | Surrogate key | 201 |
|
|
214
|
+
| PromoID | VARCHAR(20) | Business key | PROMO-2024-001 |
|
|
215
|
+
| PromoName | VARCHAR(100) | Promotion name | Summer Sale |
|
|
216
|
+
| PromoType | VARCHAR(30) | Type | Seasonal |
|
|
217
|
+
| Description | VARCHAR(500) | Full description | 20% off summer items |
|
|
218
|
+
| StartDate | DATE | Start date | 2024-06-01 |
|
|
219
|
+
| EndDate | DATE | End date | 2024-06-30 |
|
|
220
|
+
| DiscountPercent | DECIMAL(5,2) | Discount % | 20.00 |
|
|
221
|
+
| DiscountAmount | DECIMAL(10,2) | Fixed discount | NULL |
|
|
222
|
+
| MinPurchase | DECIMAL(10,2) | Minimum purchase | 50.00 |
|
|
223
|
+
| PromoCode | VARCHAR(20) | Promo code | SUMMER20 |
|
|
224
|
+
| IsActive | BIT | Currently active | 1 |
|
|
225
|
+
|
|
226
|
+
### DimEmployee (Employee Dimension - Optional)
|
|
227
|
+
|
|
228
|
+
**Purpose:** Sales associate tracking
|
|
229
|
+
|
|
230
|
+
| Column | Data Type | Description | Sample Values |
|
|
231
|
+
|--------|-----------|-------------|---------------|
|
|
232
|
+
| EmployeeKey | INT | Surrogate key | 301 |
|
|
233
|
+
| EmployeeID | VARCHAR(20) | Business key | EMP-001 |
|
|
234
|
+
| FirstName | VARCHAR(50) | First name | Sarah |
|
|
235
|
+
| LastName | VARCHAR(50) | Last name | Johnson |
|
|
236
|
+
| FullName | VARCHAR(100) | Full name | Sarah Johnson |
|
|
237
|
+
| Title | VARCHAR(50) | Job title | Sales Associate |
|
|
238
|
+
| Department | VARCHAR(50) | Department | Sales |
|
|
239
|
+
| HireDate | DATE | Hire date | 2021-03-01 |
|
|
240
|
+
| TerminationDate | DATE | Termination date | NULL |
|
|
241
|
+
| ManagerKey | INT | Manager's key | 302 |
|
|
242
|
+
| StoreKey | INT | Assigned store | 101 |
|
|
243
|
+
| Email | VARCHAR(100) | Work email | sarah.j@company.com |
|
|
244
|
+
| IsActive | BIT | Currently employed | 1 |
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Fact Tables
|
|
249
|
+
|
|
250
|
+
### FactSales (Sales Transactions)
|
|
251
|
+
|
|
252
|
+
**Purpose:** Transaction-level sales data
|
|
253
|
+
|
|
254
|
+
| Column | Data Type | Description | Grain |
|
|
255
|
+
|--------|-----------|-------------|-------|
|
|
256
|
+
| SalesKey | BIGINT | Surrogate key | One row per line item |
|
|
257
|
+
| DateKey | INT | Transaction date (FK) | |
|
|
258
|
+
| ProductKey | INT | Product (FK) | |
|
|
259
|
+
| CustomerKey | INT | Customer (FK) | |
|
|
260
|
+
| StoreKey | INT | Store (FK) | |
|
|
261
|
+
| PromoKey | INT | Promotion (FK, nullable) | |
|
|
262
|
+
| EmployeeKey | INT | Sales associate (FK, nullable) | |
|
|
263
|
+
| TransactionID | VARCHAR(30) | Transaction number | |
|
|
264
|
+
| LineNumber | INT | Line item number | |
|
|
265
|
+
| Quantity | INT | Units sold | |
|
|
266
|
+
| UnitPrice | DECIMAL(10,2) | Selling price | |
|
|
267
|
+
| UnitCost | DECIMAL(10,2) | Unit cost | |
|
|
268
|
+
| DiscountAmount | DECIMAL(10,2) | Discount applied | |
|
|
269
|
+
| TotalAmount | DECIMAL(12,2) | Line total (Qty * Price - Discount) | |
|
|
270
|
+
| TotalCost | DECIMAL(12,2) | Line cost (Qty * Cost) | |
|
|
271
|
+
| GrossProfit | DECIMAL(12,2) | TotalAmount - TotalCost | |
|
|
272
|
+
|
|
273
|
+
**Relationships:**
|
|
274
|
+
- DateKey → DimDate.DateKey (M:1)
|
|
275
|
+
- ProductKey → DimProduct.ProductKey (M:1)
|
|
276
|
+
- CustomerKey → DimCustomer.CustomerKey (M:1)
|
|
277
|
+
- StoreKey → DimStore.StoreKey (M:1)
|
|
278
|
+
- PromoKey → DimPromotion.PromoKey (M:1)
|
|
279
|
+
- EmployeeKey → DimEmployee.EmployeeKey (M:1)
|
|
280
|
+
|
|
281
|
+
### FactInventory (Inventory Snapshots)
|
|
282
|
+
|
|
283
|
+
**Purpose:** Daily inventory levels by product and store
|
|
284
|
+
|
|
285
|
+
| Column | Data Type | Description | Grain |
|
|
286
|
+
|--------|-----------|-------------|-------|
|
|
287
|
+
| InventoryKey | BIGINT | Surrogate key | One row per product per store per day |
|
|
288
|
+
| DateKey | INT | Snapshot date (FK) | |
|
|
289
|
+
| ProductKey | INT | Product (FK) | |
|
|
290
|
+
| StoreKey | INT | Store (FK) | |
|
|
291
|
+
| QuantityOnHand | INT | Current stock | |
|
|
292
|
+
| QuantityOnOrder | INT | Pending orders | |
|
|
293
|
+
| ReorderPoint | INT | Reorder trigger | |
|
|
294
|
+
| SafetyStock | INT | Safety stock level | |
|
|
295
|
+
| UnitCost | DECIMAL(10,2) | Current cost | |
|
|
296
|
+
| InventoryValue | DECIMAL(12,2) | Stock value | |
|
|
297
|
+
|
|
298
|
+
### FactSalesTarget (Sales Targets - Optional)
|
|
299
|
+
|
|
300
|
+
**Purpose:** Budget/target comparison
|
|
301
|
+
|
|
302
|
+
| Column | Data Type | Description | Grain |
|
|
303
|
+
|--------|-----------|-------------|-------|
|
|
304
|
+
| TargetKey | BIGINT | Surrogate key | One row per store per month |
|
|
305
|
+
| DateKey | INT | Month start date (FK) | |
|
|
306
|
+
| StoreKey | INT | Store (FK) | |
|
|
307
|
+
| CategoryKey | INT | Product category (optional) | |
|
|
308
|
+
| TargetAmount | DECIMAL(12,2) | Target revenue | |
|
|
309
|
+
| TargetUnits | INT | Target units | |
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## Recommended DAX Measures
|
|
314
|
+
|
|
315
|
+
### Sales Measures
|
|
316
|
+
|
|
317
|
+
```dax
|
|
318
|
+
// Total Revenue
|
|
319
|
+
Total Revenue =
|
|
320
|
+
SUM(FactSales[TotalAmount])
|
|
321
|
+
|
|
322
|
+
// Total Quantity
|
|
323
|
+
Total Quantity =
|
|
324
|
+
SUM(FactSales[Quantity])
|
|
325
|
+
|
|
326
|
+
// Total Cost
|
|
327
|
+
Total Cost =
|
|
328
|
+
SUM(FactSales[TotalCost])
|
|
329
|
+
|
|
330
|
+
// Gross Profit
|
|
331
|
+
Gross Profit =
|
|
332
|
+
[Total Revenue] - [Total Cost]
|
|
333
|
+
|
|
334
|
+
// Gross Margin %
|
|
335
|
+
Gross Margin % =
|
|
336
|
+
DIVIDE([Gross Profit], [Total Revenue])
|
|
337
|
+
|
|
338
|
+
// Average Transaction Value
|
|
339
|
+
Avg Transaction Value =
|
|
340
|
+
DIVIDE(
|
|
341
|
+
[Total Revenue],
|
|
342
|
+
DISTINCTCOUNT(FactSales[TransactionID])
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
// Average Unit Price
|
|
346
|
+
Avg Unit Price =
|
|
347
|
+
DIVIDE([Total Revenue], [Total Quantity])
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Time Intelligence
|
|
351
|
+
|
|
352
|
+
```dax
|
|
353
|
+
// Revenue YTD
|
|
354
|
+
Revenue YTD =
|
|
355
|
+
TOTALYTD([Total Revenue], DimDate[Date])
|
|
356
|
+
|
|
357
|
+
// Revenue Previous Year
|
|
358
|
+
Revenue PY =
|
|
359
|
+
CALCULATE(
|
|
360
|
+
[Total Revenue],
|
|
361
|
+
SAMEPERIODLASTYEAR(DimDate[Date])
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
// Revenue YoY Growth
|
|
365
|
+
Revenue YoY % =
|
|
366
|
+
DIVIDE([Total Revenue] - [Revenue PY], [Revenue PY])
|
|
367
|
+
|
|
368
|
+
// Revenue Running Total
|
|
369
|
+
Revenue Running Total =
|
|
370
|
+
CALCULATE(
|
|
371
|
+
[Total Revenue],
|
|
372
|
+
FILTER(
|
|
373
|
+
ALLSELECTED(DimDate[Date]),
|
|
374
|
+
DimDate[Date] <= MAX(DimDate[Date])
|
|
375
|
+
)
|
|
376
|
+
)
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### Customer Metrics
|
|
380
|
+
|
|
381
|
+
```dax
|
|
382
|
+
// Customer Count
|
|
383
|
+
Customer Count =
|
|
384
|
+
DISTINCTCOUNT(FactSales[CustomerKey])
|
|
385
|
+
|
|
386
|
+
// New Customers
|
|
387
|
+
New Customers =
|
|
388
|
+
CALCULATE(
|
|
389
|
+
DISTINCTCOUNT(FactSales[CustomerKey]),
|
|
390
|
+
FILTER(
|
|
391
|
+
DimCustomer,
|
|
392
|
+
DimCustomer[JoinDate] >= MIN(DimDate[Date])
|
|
393
|
+
&& DimCustomer[JoinDate] <= MAX(DimDate[Date])
|
|
394
|
+
)
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
// Average Revenue per Customer
|
|
398
|
+
Revenue per Customer =
|
|
399
|
+
DIVIDE([Total Revenue], [Customer Count])
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Inventory Metrics
|
|
403
|
+
|
|
404
|
+
```dax
|
|
405
|
+
// Current Inventory Value
|
|
406
|
+
Current Inventory Value =
|
|
407
|
+
CALCULATE(
|
|
408
|
+
SUM(FactInventory[InventoryValue]),
|
|
409
|
+
LASTDATE(DimDate[Date])
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
// Days of Inventory
|
|
413
|
+
Days of Inventory =
|
|
414
|
+
DIVIDE(
|
|
415
|
+
[Current Inventory Value],
|
|
416
|
+
DIVIDE([Total Cost], 365)
|
|
417
|
+
)
|
|
418
|
+
|
|
419
|
+
// Stockout Risk
|
|
420
|
+
Stockout Risk =
|
|
421
|
+
CALCULATE(
|
|
422
|
+
COUNTROWS(FactInventory),
|
|
423
|
+
FactInventory[QuantityOnHand] <= FactInventory[ReorderPoint]
|
|
424
|
+
)
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
## Implementation Notes
|
|
430
|
+
|
|
431
|
+
### Relationship Configuration
|
|
432
|
+
|
|
433
|
+
- All relationships: Single direction (default)
|
|
434
|
+
- Cross-filter: Single direction (fact → dimension)
|
|
435
|
+
- Use Role-Playing Dimensions for multiple date relationships
|
|
436
|
+
- Example: OrderDate, ShipDate → Create separate date tables or inactive relationships
|
|
437
|
+
|
|
438
|
+
### Performance Optimization
|
|
439
|
+
|
|
440
|
+
1. **Partition FactSales** by year for incremental refresh
|
|
441
|
+
2. **Index foreign keys** in source database
|
|
442
|
+
3. **Avoid high-cardinality** columns in dimensions
|
|
443
|
+
4. **Pre-aggregate** for common aggregations if performance issues
|
|
444
|
+
|
|
445
|
+
### Data Types
|
|
446
|
+
|
|
447
|
+
- Use INT for keys, not VARCHAR
|
|
448
|
+
- Use DECIMAL(10,2) for currency
|
|
449
|
+
- Avoid FLOAT for financial data
|
|
450
|
+
- Use DATE not DATETIME when time not needed
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## Implementation Checklist
|
|
455
|
+
|
|
456
|
+
- [ ] Create DimDate with full calendar and fiscal year support
|
|
457
|
+
- [ ] Load product hierarchy (Category > SubCategory > Brand)
|
|
458
|
+
- [ ] Configure customer segmentation logic
|
|
459
|
+
- [ ] Set up store geography hierarchy
|
|
460
|
+
- [ ] Build FactSales with appropriate grain
|
|
461
|
+
- [ ] Create all relationships (star schema)
|
|
462
|
+
- [ ] Build core measure groups
|
|
463
|
+
- [ ] Test time intelligence calculations
|
|
464
|
+
- [ ] Configure incremental refresh for FactSales
|
|
465
|
+
- [ ] Document business rules and calculations
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
## Related Resources
|
|
470
|
+
|
|
471
|
+
- [Star Schema Best Practices](../../skills/data-modeling/SKILL.md)
|
|
472
|
+
- [DAX Time Intelligence](../../snippets/dax/time-intelligence.md)
|
|
473
|
+
- [Sales Dashboard Template](../power-bi/sales-dashboard.md)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Excel Templates
|
|
2
|
+
|
|
3
|
+
Comprehensive workbook specifications and implementation guides for common Excel use cases.
|
|
4
|
+
|
|
5
|
+
## Available Templates
|
|
6
|
+
|
|
7
|
+
| Template | Description | Complexity |
|
|
8
|
+
|----------|-------------|------------|
|
|
9
|
+
| [Budget Tracker](./budget-tracker.md) | Department/project budget tracking with variance analysis | Medium |
|
|
10
|
+
| [Data Entry Form](./data-entry-form.md) | Standardized data collection with validation | Medium |
|
|
11
|
+
|
|
12
|
+
## What's Included
|
|
13
|
+
|
|
14
|
+
Each template specification includes:
|
|
15
|
+
|
|
16
|
+
- **Workbook Structure** - Sheet organization and purpose
|
|
17
|
+
- **Data Layout** - Column definitions and table structures
|
|
18
|
+
- **Key Formulas** - Excel formulas ready to implement
|
|
19
|
+
- **Data Validation** - Rules for error prevention
|
|
20
|
+
- **Conditional Formatting** - Visual indicators and highlighting
|
|
21
|
+
- **Protection Settings** - Security recommendations
|
|
22
|
+
- **Implementation Checklist** - Step-by-step verification
|
|
23
|
+
|
|
24
|
+
## How to Use
|
|
25
|
+
|
|
26
|
+
1. **Review the specification** - Understand workbook structure and requirements
|
|
27
|
+
2. **Create sheets** - Set up the recommended sheet structure
|
|
28
|
+
3. **Build tables** - Create Excel Tables with specified columns
|
|
29
|
+
4. **Add formulas** - Implement calculation logic
|
|
30
|
+
5. **Configure validation** - Set up dropdowns and input rules
|
|
31
|
+
6. **Apply formatting** - Conditional formatting and visual design
|
|
32
|
+
7. **Protect workbook** - Apply appropriate protection
|
|
33
|
+
|
|
34
|
+
## Template Categories
|
|
35
|
+
|
|
36
|
+
### Financial
|
|
37
|
+
- Budget Tracker - Budget vs actual tracking
|
|
38
|
+
|
|
39
|
+
### Data Collection
|
|
40
|
+
- Data Entry Form - Standardized input with validation
|
|
41
|
+
|
|
42
|
+
### Coming Soon
|
|
43
|
+
- Invoice Template - Professional invoicing
|
|
44
|
+
- Project Timeline - Gantt chart and milestones
|
|
45
|
+
- Inventory Manager - Stock tracking and reorder
|
|
46
|
+
- Employee Scheduler - Shift planning
|
|
47
|
+
|
|
48
|
+
## Best Practices
|
|
49
|
+
|
|
50
|
+
### Excel Tables
|
|
51
|
+
All data should be in Excel Tables for:
|
|
52
|
+
- Automatic range expansion
|
|
53
|
+
- Structured references in formulas
|
|
54
|
+
- Easier filtering and sorting
|
|
55
|
+
- Better Power Query connectivity
|
|
56
|
+
|
|
57
|
+
### Naming Conventions
|
|
58
|
+
- Tables: `tbl_TableName`
|
|
59
|
+
- Named Ranges: `rng_RangeName`
|
|
60
|
+
- Parameters: `param_ParameterName`
|
|
61
|
+
|
|
62
|
+
### Formula Approach
|
|
63
|
+
Templates use modern Excel 365 formulas where possible:
|
|
64
|
+
- XLOOKUP over VLOOKUP
|
|
65
|
+
- FILTER, SORT, UNIQUE for dynamic arrays
|
|
66
|
+
- LET for readable complex formulas
|
|
67
|
+
- LAMBDA for reusable custom functions
|
|
68
|
+
|
|
69
|
+
## Related Resources
|
|
70
|
+
|
|
71
|
+
- [Excel Formula Snippets](../../snippets/excel-formulas/) - Formula patterns
|
|
72
|
+
- [Excel Styles](../../styles/excel/) - Formatting guidelines
|
|
73
|
+
- [Excel Formulas Skill](../../skills/excel-formulas/) - AI assistance for formulas
|
|
74
|
+
|
|
75
|
+
## Contributing
|
|
76
|
+
|
|
77
|
+
To contribute a new template:
|
|
78
|
+
|
|
79
|
+
1. Use an existing template as a reference for structure
|
|
80
|
+
2. Include all required sections (Structure, Formulas, Validation)
|
|
81
|
+
3. Provide working formula examples
|
|
82
|
+
4. Test with sample data
|
|
83
|
+
5. Submit a PR with the template markdown file
|