@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.
Files changed (193) hide show
  1. package/.claude-plugin/plugin.json +8 -0
  2. package/.mcp.json +25 -0
  3. package/AGENTS.md +244 -0
  4. package/CHANGELOG.md +265 -0
  5. package/LICENSE +21 -0
  6. package/README.md +211 -0
  7. package/bin/build-plugin.js +30 -0
  8. package/bin/cli.js +1064 -0
  9. package/bin/commands/add.js +533 -0
  10. package/bin/commands/add.test.js +77 -0
  11. package/bin/commands/build-desktop.js +166 -0
  12. package/bin/commands/changelog.js +443 -0
  13. package/bin/commands/diff.js +325 -0
  14. package/bin/commands/lint.js +419 -0
  15. package/bin/commands/lint.test.js +103 -0
  16. package/bin/commands/mcp-setup.js +246 -0
  17. package/bin/commands/pull.js +287 -0
  18. package/bin/commands/pull.test.js +36 -0
  19. package/bin/commands/push.js +231 -0
  20. package/bin/commands/push.test.js +14 -0
  21. package/bin/commands/search.js +344 -0
  22. package/bin/commands/search.test.js +115 -0
  23. package/bin/commands/setup.js +545 -0
  24. package/bin/commands/setup.test.js +46 -0
  25. package/bin/commands/sync-profile.js +405 -0
  26. package/bin/commands/sync-profile.test.js +14 -0
  27. package/bin/commands/sync-source.js +418 -0
  28. package/bin/commands/sync-source.test.js +14 -0
  29. package/bin/commands/watch.js +206 -0
  30. package/bin/lib/generators/claude-plugin.js +266 -0
  31. package/bin/lib/generators/claude-plugin.test.js +110 -0
  32. package/bin/lib/generators/index.js +116 -0
  33. package/bin/lib/generators/shared.js +282 -0
  34. package/bin/lib/licensing/index.js +35 -0
  35. package/bin/lib/licensing/storage.js +364 -0
  36. package/bin/lib/licensing/storage.test.js +55 -0
  37. package/bin/lib/licensing/validator.js +213 -0
  38. package/bin/lib/licensing/validator.test.js +137 -0
  39. package/bin/lib/microsoft-mcp.js +176 -0
  40. package/bin/lib/microsoft-mcp.test.js +106 -0
  41. package/bin/lib/skills.js +84 -0
  42. package/bin/mcp/powerbi-modeling-launcher.js +38 -0
  43. package/bin/postinstall.js +44 -0
  44. package/bin/utils/errors.js +159 -0
  45. package/bin/utils/git.js +298 -0
  46. package/bin/utils/logger.js +142 -0
  47. package/bin/utils/mcp-detect.js +274 -0
  48. package/bin/utils/mcp-detect.test.js +105 -0
  49. package/bin/utils/pbix.js +305 -0
  50. package/bin/utils/pbix.test.js +37 -0
  51. package/bin/utils/profiles.js +312 -0
  52. package/bin/utils/projects.js +168 -0
  53. package/bin/utils/readline.js +206 -0
  54. package/bin/utils/readline.test.js +47 -0
  55. package/bin/utils/tui.js +314 -0
  56. package/bin/utils/tui.test.js +127 -0
  57. package/commands/contributions.md +265 -0
  58. package/commands/data-model-design.md +468 -0
  59. package/commands/dax-doctor.md +248 -0
  60. package/commands/fabric-scripts.md +452 -0
  61. package/commands/migration-assistant.md +290 -0
  62. package/commands/model-documenter.md +242 -0
  63. package/commands/pbi-connect.md +239 -0
  64. package/commands/project-kickoff.md +905 -0
  65. package/commands/report-layout.md +296 -0
  66. package/commands/rls-design.md +533 -0
  67. package/commands/theme-tweaker.md +624 -0
  68. package/config.example.json +23 -0
  69. package/config.json +23 -0
  70. package/desktop-extension/manifest.json +37 -0
  71. package/desktop-extension/package.json +10 -0
  72. package/desktop-extension/server.js +95 -0
  73. package/docs/openrouter-free-models.md +92 -0
  74. package/library/examples/README.md +151 -0
  75. package/library/examples/finance-reporting/README.md +351 -0
  76. package/library/examples/finance-reporting/data-model.md +267 -0
  77. package/library/examples/finance-reporting/measures.dax +557 -0
  78. package/library/examples/hr-analytics/README.md +371 -0
  79. package/library/examples/hr-analytics/data-model.md +315 -0
  80. package/library/examples/hr-analytics/measures.dax +460 -0
  81. package/library/examples/marketing-analytics/README.md +37 -0
  82. package/library/examples/marketing-analytics/data-model.md +62 -0
  83. package/library/examples/marketing-analytics/measures.dax +110 -0
  84. package/library/examples/retail-analytics/README.md +439 -0
  85. package/library/examples/retail-analytics/data-model.md +288 -0
  86. package/library/examples/retail-analytics/measures.dax +481 -0
  87. package/library/examples/supply-chain/README.md +37 -0
  88. package/library/examples/supply-chain/data-model.md +69 -0
  89. package/library/examples/supply-chain/measures.dax +77 -0
  90. package/library/examples/udf-library/README.md +228 -0
  91. package/library/examples/udf-library/functions.dax +571 -0
  92. package/library/snippets/dax/README.md +292 -0
  93. package/library/snippets/dax/business-domains.md +576 -0
  94. package/library/snippets/dax/calculate-patterns.md +276 -0
  95. package/library/snippets/dax/calculation-groups.md +489 -0
  96. package/library/snippets/dax/error-handling.md +495 -0
  97. package/library/snippets/dax/iterators-and-aggregations.md +474 -0
  98. package/library/snippets/dax/kpis-and-metrics.md +293 -0
  99. package/library/snippets/dax/rankings-and-topn.md +235 -0
  100. package/library/snippets/dax/security-patterns.md +413 -0
  101. package/library/snippets/dax/text-and-formatting.md +316 -0
  102. package/library/snippets/dax/time-intelligence.md +196 -0
  103. package/library/snippets/dax/user-defined-functions.md +477 -0
  104. package/library/snippets/dax/virtual-tables.md +546 -0
  105. package/library/snippets/excel-formulas/README.md +84 -0
  106. package/library/snippets/excel-formulas/aggregations.md +330 -0
  107. package/library/snippets/excel-formulas/dates-and-times.md +361 -0
  108. package/library/snippets/excel-formulas/dynamic-arrays.md +314 -0
  109. package/library/snippets/excel-formulas/lookups.md +169 -0
  110. package/library/snippets/excel-formulas/text-functions.md +363 -0
  111. package/library/snippets/governance/naming-conventions.md +97 -0
  112. package/library/snippets/governance/review-checklists.md +107 -0
  113. package/library/snippets/power-query/README.md +389 -0
  114. package/library/snippets/power-query/api-integration.md +707 -0
  115. package/library/snippets/power-query/connections.md +434 -0
  116. package/library/snippets/power-query/data-cleaning.md +298 -0
  117. package/library/snippets/power-query/error-handling.md +526 -0
  118. package/library/snippets/power-query/parameters.md +350 -0
  119. package/library/snippets/power-query/performance.md +506 -0
  120. package/library/snippets/power-query/transformations.md +330 -0
  121. package/library/snippets/report-design/accessibility.md +78 -0
  122. package/library/snippets/report-design/chart-selection.md +54 -0
  123. package/library/snippets/report-design/layout-patterns.md +87 -0
  124. package/library/templates/data-models/README.md +93 -0
  125. package/library/templates/data-models/finance-model.md +627 -0
  126. package/library/templates/data-models/retail-star-schema.md +473 -0
  127. package/library/templates/excel/README.md +83 -0
  128. package/library/templates/excel/budget-tracker.md +432 -0
  129. package/library/templates/excel/data-entry-form.md +533 -0
  130. package/library/templates/power-bi/README.md +72 -0
  131. package/library/templates/power-bi/finance-report.md +449 -0
  132. package/library/templates/power-bi/kpi-scorecard.md +461 -0
  133. package/library/templates/power-bi/sales-dashboard.md +281 -0
  134. package/library/themes/excel/README.md +436 -0
  135. package/library/themes/power-bi/README.md +271 -0
  136. package/library/themes/power-bi/accessible.json +307 -0
  137. package/library/themes/power-bi/bi-superpowers-default.json +858 -0
  138. package/library/themes/power-bi/corporate-blue.json +291 -0
  139. package/library/themes/power-bi/dark-mode.json +291 -0
  140. package/library/themes/power-bi/minimal.json +292 -0
  141. package/library/themes/power-bi/print-friendly.json +309 -0
  142. package/package.json +93 -0
  143. package/skills/contributions/SKILL.md +267 -0
  144. package/skills/data-model-design/SKILL.md +470 -0
  145. package/skills/data-modeling/SKILL.md +254 -0
  146. package/skills/data-quality/SKILL.md +664 -0
  147. package/skills/dax/SKILL.md +708 -0
  148. package/skills/dax-doctor/SKILL.md +250 -0
  149. package/skills/dax-udf/SKILL.md +489 -0
  150. package/skills/deployment/SKILL.md +320 -0
  151. package/skills/excel-formulas/SKILL.md +463 -0
  152. package/skills/fabric-scripts/SKILL.md +454 -0
  153. package/skills/fast-standard/SKILL.md +509 -0
  154. package/skills/governance/SKILL.md +205 -0
  155. package/skills/migration-assistant/SKILL.md +292 -0
  156. package/skills/model-documenter/SKILL.md +244 -0
  157. package/skills/pbi-connect/SKILL.md +241 -0
  158. package/skills/power-query/SKILL.md +406 -0
  159. package/skills/project-kickoff/SKILL.md +907 -0
  160. package/skills/query-performance/SKILL.md +480 -0
  161. package/skills/report-design/SKILL.md +207 -0
  162. package/skills/report-layout/SKILL.md +298 -0
  163. package/skills/rls-design/SKILL.md +535 -0
  164. package/skills/semantic-model/SKILL.md +237 -0
  165. package/skills/testing-validation/SKILL.md +643 -0
  166. package/skills/theme-tweaker/SKILL.md +626 -0
  167. package/src/content/base.md +237 -0
  168. package/src/content/mcp-requirements.json +69 -0
  169. package/src/content/routing.md +203 -0
  170. package/src/content/skills/contributions.md +259 -0
  171. package/src/content/skills/data-model-design.md +462 -0
  172. package/src/content/skills/data-modeling.md +246 -0
  173. package/src/content/skills/data-quality.md +656 -0
  174. package/src/content/skills/dax-doctor.md +242 -0
  175. package/src/content/skills/dax-udf.md +481 -0
  176. package/src/content/skills/dax.md +700 -0
  177. package/src/content/skills/deployment.md +312 -0
  178. package/src/content/skills/excel-formulas.md +455 -0
  179. package/src/content/skills/fabric-scripts.md +446 -0
  180. package/src/content/skills/fast-standard.md +501 -0
  181. package/src/content/skills/governance.md +197 -0
  182. package/src/content/skills/migration-assistant.md +284 -0
  183. package/src/content/skills/model-documenter.md +236 -0
  184. package/src/content/skills/pbi-connect.md +233 -0
  185. package/src/content/skills/power-query.md +398 -0
  186. package/src/content/skills/project-kickoff.md +899 -0
  187. package/src/content/skills/query-performance.md +472 -0
  188. package/src/content/skills/report-design.md +199 -0
  189. package/src/content/skills/report-layout.md +290 -0
  190. package/src/content/skills/rls-design.md +527 -0
  191. package/src/content/skills/semantic-model.md +229 -0
  192. package/src/content/skills/testing-validation.md +635 -0
  193. package/src/content/skills/theme-tweaker.md +618 -0
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * BI Agent Superpowers — MCP Server for Claude Desktop
5
+ *
6
+ * Lightweight MCP server that exposes all 24 BI skills as prompts.
7
+ * Bundled into a .mcpb extension via `super build-desktop`.
8
+ *
9
+ * Skills are loaded from the ./skills/ directory (copied at build time).
10
+ */
11
+
12
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
13
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
14
+ import fs from 'fs';
15
+ import path from 'path';
16
+ import { fileURLToPath } from 'url';
17
+
18
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
19
+ const skillsDir = path.join(__dirname, 'skills');
20
+
21
+ // Create the MCP server instance
22
+ const server = new McpServer({
23
+ name: 'bi-superpowers',
24
+ version: '0.0.0-template',
25
+ });
26
+
27
+ // Load all skill markdown files from the bundled skills/ directory
28
+ const skillFiles = fs.existsSync(skillsDir)
29
+ ? fs.readdirSync(skillsDir).filter((f) => f.endsWith('.md'))
30
+ : [];
31
+
32
+ // Register each skill as an MCP prompt that Claude Desktop can invoke
33
+ for (const file of skillFiles) {
34
+ const name = path.basename(file, '.md');
35
+ const content = fs.readFileSync(path.join(skillsDir, file), 'utf8');
36
+
37
+ // Extract first line as description (skip markdown headers)
38
+ const firstLine = content
39
+ .split('\n')
40
+ .find((l) => l.trim() && !l.startsWith('#'));
41
+ const description = firstLine
42
+ ? firstLine.slice(0, 120).trim()
43
+ : `BI Superpowers: ${name}`;
44
+
45
+ server.prompt(name, { description }, () => ({
46
+ messages: [
47
+ {
48
+ role: 'user',
49
+ content: { type: 'text', text: content },
50
+ },
51
+ ],
52
+ }));
53
+ }
54
+
55
+ // Register a setup-mcp helper prompt with Power BI/Fabric/Excel MCP instructions
56
+ server.prompt(
57
+ 'setup-mcp',
58
+ { description: 'Instructions to configure Power BI, Fabric & Excel MCP servers in Claude Desktop' },
59
+ () => ({
60
+ messages: [
61
+ {
62
+ role: 'user',
63
+ content: {
64
+ type: 'text',
65
+ text: `# Configure MCP Servers for Claude Desktop
66
+
67
+ To connect Power BI, Fabric, and Excel to Claude Desktop, add the following
68
+ to your \`claude_desktop_config.json\` (Settings > Developer > Edit Config):
69
+
70
+ \`\`\`json
71
+ {
72
+ "mcpServers": {
73
+ "powerbi-remote": {
74
+ "command": "npx",
75
+ "args": ["-y", "@anthropic-ai/mcp-remote", "https://mcp.powerbi.com/sse"]
76
+ },
77
+ "fabric-mcp-server": {
78
+ "command": "npx",
79
+ "args": ["-y", "@anthropic-ai/mcp-remote", "https://mcp.fabric.microsoft.com/v1/sse"]
80
+ }
81
+ }
82
+ }
83
+ \`\`\`
84
+
85
+ After saving, restart Claude Desktop. The MCP servers will appear in your tools.
86
+ `,
87
+ },
88
+ },
89
+ ],
90
+ })
91
+ );
92
+
93
+ // Start the server with stdio transport
94
+ const transport = new StdioServerTransport();
95
+ await server.connect(transport);
@@ -0,0 +1,92 @@
1
+ # Configure Claude Code with OpenRouter (Free Models)
2
+
3
+ Use free AI models with Claude Code CLI and 1code.dev via OpenRouter.
4
+
5
+ ## Prerequisites
6
+
7
+ - Node.js installed
8
+ - Claude Code CLI installed (`npm install -g @anthropic-ai/claude-code`)
9
+ - Free account at [openrouter.ai](https://openrouter.ai)
10
+
11
+ ## Step 1: Create OpenRouter API Key
12
+
13
+ 1. Go to [openrouter.ai](https://openrouter.ai) and create account (free)
14
+ 2. Go to [openrouter.ai/keys](https://openrouter.ai/keys)
15
+ 3. Click "Create Key"
16
+ 4. Copy the key (starts with `sk-or-v1-...`)
17
+
18
+ ## Step 2: Configure Environment Variables
19
+
20
+ Add to the end of `~/.zshrc` (macOS/Linux) or your shell profile:
21
+
22
+ ```bash
23
+ # OpenRouter + Claude Code
24
+ export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
25
+ export ANTHROPIC_AUTH_TOKEN="sk-or-v1-YOUR-KEY-HERE"
26
+ export ANTHROPIC_API_KEY=""
27
+ ```
28
+
29
+ > **Important**: `ANTHROPIC_API_KEY` MUST be empty (`""`). If it doesn't exist, Claude Code will try to authenticate with Anthropic directly.
30
+
31
+ Then reload the shell:
32
+
33
+ ```bash
34
+ source ~/.zshrc
35
+ ```
36
+
37
+ ## Step 3: Sign Out of Anthropic (if needed)
38
+
39
+ If you previously used Claude Code with an Anthropic account:
40
+
41
+ ```bash
42
+ claude
43
+ # inside the session:
44
+ /logout
45
+ ```
46
+
47
+ ## Step 4: Verify Connection
48
+
49
+ ```bash
50
+ claude
51
+ # inside the session:
52
+ /status
53
+ ```
54
+
55
+ Should show that it's connected to OpenRouter.
56
+
57
+ ## Recommended Free Models for Coding
58
+
59
+ | Model | OpenRouter ID | Context | Best For |
60
+ |-------|---------------|---------|----------|
61
+ | **Qwen3 Coder 480B** | `qwen/qwen3-coder-480b-a35b:free` | 262K | Best free model for agentic coding |
62
+ | **DeepSeek R1** | `deepseek/deepseek-r1:free` | 164K | Complex reasoning, debugging |
63
+ | **Devstral** | `mistralai/devstral-small:free` | 128K | Multi-file, agentic coding |
64
+ | **Llama 3.3 70B** | `meta-llama/llama-3.3-70b-instruct:free` | 128K | General purpose, fast |
65
+
66
+ To select a specific model, add to `~/.zshrc`:
67
+
68
+ ```bash
69
+ export ANTHROPIC_MODEL="qwen/qwen3-coder-480b-a35b:free"
70
+ ```
71
+
72
+ Or use the free automatic router:
73
+
74
+ ```bash
75
+ export ANTHROPIC_MODEL="openrouter/free"
76
+ ```
77
+
78
+ ## Limitations
79
+
80
+ - **Rate limits**: ~20 requests/min, ~200 requests/day on free models
81
+ - **Tool use**: Not all free models support tool calling (needed for agents)
82
+ - **Quality**: Inferior to Claude Opus/Sonnet for complex tasks
83
+ - **Availability**: Free models may disappear without notice
84
+ - **Not recommended for production**
85
+
86
+ ## Verification
87
+
88
+ 1. Open a new terminal (to load the variables)
89
+ 2. `echo $ANTHROPIC_BASE_URL` → should show `https://openrouter.ai/api`
90
+ 3. `claude` → should start without asking for Anthropic login
91
+ 4. `/status` → confirm connection to OpenRouter
92
+ 5. Ask a simple coding question to verify response
@@ -0,0 +1,151 @@
1
+ # Examples
2
+
3
+ Complete, end-to-end examples demonstrating BI Agent Superpowers patterns in real-world scenarios.
4
+
5
+ ---
6
+
7
+ ## Available Examples
8
+
9
+ | Example | Description | Components |
10
+ |---------|-------------|------------|
11
+ | [retail-analytics](./retail-analytics/) | Complete retail sales analytics solution | Star schema, 50+ DAX measures, data model |
12
+ | [finance-reporting](./finance-reporting/) | P&L, Balance Sheet, variance analysis | Multi-statement model, 60+ financial measures |
13
+ | [hr-analytics](./hr-analytics/) | Headcount, turnover, diversity metrics | Employee snapshots, 40+ HR measures |
14
+ | [udf-library](./udf-library/) | DAX User Defined Functions library | 50+ reusable UDFs, typed parameters |
15
+
16
+ ---
17
+
18
+ ## Learning Path (Recommended Order)
19
+
20
+ New to Power BI? Follow this progression to build your skills:
21
+
22
+ ### Level 1: Foundations
23
+ 1. **[retail-analytics](./retail-analytics/)** - Start here!
24
+ - Learn star schema basics (facts + dimensions)
25
+ - Understand fundamental DAX patterns (SUM, CALCULATE, time intelligence)
26
+ - Build your first KPI dashboard
27
+
28
+ ### Level 2: Intermediate
29
+ 2. **[hr-analytics](./hr-analytics/)** - Expand your skills
30
+ - Work with snapshot data (point-in-time analysis)
31
+ - Learn turnover and retention calculations
32
+ - Understand Row-Level Security (RLS) basics
33
+
34
+ ### Level 3: Advanced
35
+ 3. **[finance-reporting](./finance-reporting/)** - Master complex scenarios
36
+ - Handle multi-statement financial models
37
+ - Work with hierarchical account structures
38
+ - Build variance analysis (Actual vs Budget)
39
+
40
+ ### Level 4: Expert
41
+ 4. **[udf-library](./udf-library/)** - Cutting-edge DAX
42
+ - Create reusable User Defined Functions (preview feature)
43
+ - Build a personal library of typed functions
44
+ - Master advanced DAX patterns
45
+
46
+ ---
47
+
48
+ ## What Each Example Includes
49
+
50
+ ### Documentation
51
+ - **README.md** - Overview, business requirements, implementation guide
52
+ - **data-model.md** - Complete table definitions, relationships, sample data
53
+
54
+ ### Code
55
+ - **measures.dax** - Complete DAX measure library, organized by category
56
+
57
+ ### Styling
58
+ - Use themes from `library/themes/power-bi/` for consistent formatting
59
+
60
+ ---
61
+
62
+ ## Using Examples
63
+
64
+ ### 1. Understand the Scenario
65
+
66
+ Read the README.md to understand:
67
+ - Business requirements and stakeholders
68
+ - Key questions the solution answers
69
+ - Recommended visualizations
70
+
71
+ ### 2. Adapt the Data Model
72
+
73
+ Use data-model.md as a template:
74
+ - Match columns to your source data
75
+ - Adjust data types as needed
76
+ - Add/remove columns for your scenario
77
+
78
+ ### 3. Copy Relevant Measures
79
+
80
+ From measures.dax:
81
+ - Start with base measures (Revenue, Cost, Profit)
82
+ - Add time intelligence as needed
83
+ - Customize rankings and percentages
84
+
85
+ ### 4. Apply a Theme
86
+
87
+ 1. Choose a theme from `library/themes/power-bi/`
88
+ 2. View > Themes > Browse for themes
89
+ 3. Select the JSON file
90
+
91
+ ---
92
+
93
+ ## Example Structure
94
+
95
+ ```
96
+ library/examples/
97
+ ├── README.md # This file
98
+
99
+ ├── retail-analytics/ # Retail sales analytics
100
+ │ ├── README.md # Overview and guide
101
+ │ ├── data-model.md # Table definitions
102
+ │ └── measures.dax # 50+ DAX measures
103
+
104
+ ├── finance-reporting/ # Financial statements
105
+ │ ├── README.md # P&L, Balance Sheet guide
106
+ │ ├── data-model.md # Account structure, scenarios
107
+ │ └── measures.dax # 60+ financial measures
108
+
109
+ ├── hr-analytics/ # HR workforce analytics
110
+ │ ├── README.md # Headcount, turnover guide
111
+ │ ├── data-model.md # Employee snapshot model
112
+ │ └── measures.dax # 40+ HR measures
113
+
114
+ └── udf-library/ # DAX User Defined Functions
115
+ ├── README.md # UDF usage guide and catalog
116
+ └── functions.dax # 50+ reusable typed functions
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Upcoming Examples
122
+
123
+ - **marketing-dashboard** - Campaign performance, funnel analysis
124
+ - **supply-chain** - Inventory, fulfillment, vendor performance
125
+ - **project-management** - Resource allocation, timeline tracking
126
+
127
+ ---
128
+
129
+ ## Contributing Examples
130
+
131
+ Want to add an example? Include:
132
+
133
+ 1. **README.md** with:
134
+ - Business scenario description
135
+ - Stakeholder requirements
136
+ - Data model diagram
137
+ - Visualization recommendations
138
+ - Implementation checklist
139
+
140
+ 2. **data-model.md** with:
141
+ - All table definitions
142
+ - Column specifications
143
+ - Relationship diagram
144
+ - Sample data
145
+
146
+ 3. **measures.dax** with:
147
+ - Organized by category
148
+ - Comments explaining each measure
149
+ - Naming conventions followed
150
+
151
+ See [CONTRIBUTING.md](../../CONTRIBUTING.md) for submission guidelines.
@@ -0,0 +1,351 @@
1
+ # Finance Reporting - Complete Example
2
+
3
+ A comprehensive financial reporting solution for P&L, Balance Sheet, and Cash Flow analysis.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ This example demonstrates building a complete financial reporting solution using:
10
+
11
+ - **Multi-statement data model** supporting P&L, Balance Sheet, and Cash Flow
12
+ - **DAX measures** for period comparisons, variances, and financial ratios
13
+ - **Budget vs Actual** analysis with variance explanations
14
+ - **Rolling forecasts** and trend analysis
15
+
16
+ ---
17
+
18
+ ## Business Requirements
19
+
20
+ ### Stakeholders
21
+ - CFO: Executive financial overview
22
+ - Controllers: Detailed variance analysis
23
+ - FP&A Team: Budget tracking and forecasting
24
+ - Business Unit Leaders: Departmental P&L
25
+
26
+ ### Key Questions
27
+ 1. How are we performing vs. budget and prior year?
28
+ 2. What's driving variance from plan?
29
+ 3. What are our key financial ratios and trends?
30
+ 4. How does each department/cost center perform?
31
+ 5. What's the cash position and forecast?
32
+
33
+ ---
34
+
35
+ ## Data Model
36
+
37
+ ### Star Schema Design
38
+
39
+ ```
40
+ ┌─────────────────┐
41
+ │ DimDate │
42
+ │─────────────────│
43
+ │ DateKey (PK) │
44
+ │ Date │
45
+ │ FiscalYear │
46
+ │ FiscalPeriod │
47
+ │ FiscalQuarter │
48
+ │ IsCurrentPeriod │
49
+ └────────┬────────┘
50
+
51
+ ┌─────────────────┐ │ ┌─────────────────┐
52
+ │ DimAccount │ │ │ DimCostCenter │
53
+ │─────────────────│ │ │─────────────────│
54
+ │ AccountKey (PK) │ │ │ CostCenterKey │
55
+ │ AccountCode │ │ │ CostCenterCode │
56
+ │ AccountName │ │ │ CostCenterName │
57
+ │ AccountType │ │ │ Department │
58
+ │ AccountGroup │ │ │ Division │
59
+ │ FinancialStmt │ │ │ Manager │
60
+ │ NaturalSign │ │ └────────┬────────┘
61
+ │ SortOrder │ │ │
62
+ └────────┬────────┘ │ │
63
+ │ ┌─────────────┴───────────────┐ │
64
+ │ │ FactFinancials │ │
65
+ │ │─────────────────────────────│ │
66
+ └────>│ FinancialKey (PK) │<──┘
67
+ │ DateKey (FK) │
68
+ │ AccountKey (FK) │
69
+ │ CostCenterKey (FK) │
70
+ │ ScenarioKey (FK) │
71
+ │ Amount │
72
+ └─────────────┬───────────────┘
73
+
74
+ ┌────────┴────────┐
75
+ │ DimScenario │
76
+ │─────────────────│
77
+ │ ScenarioKey (PK)│
78
+ │ ScenarioName │
79
+ │ ScenarioType │
80
+ │ IsActual │
81
+ └─────────────────┘
82
+ ```
83
+
84
+ ### Account Types
85
+
86
+ | AccountType | FinancialStatement | NaturalSign | Examples |
87
+ |-------------|-------------------|-------------|----------|
88
+ | Revenue | Income Statement | Credit (+) | Sales, Service Revenue |
89
+ | COGS | Income Statement | Debit (-) | Cost of Goods Sold |
90
+ | OpEx | Income Statement | Debit (-) | Salaries, Rent, Marketing |
91
+ | OtherIncome | Income Statement | Credit (+) | Interest Income |
92
+ | OtherExpense | Income Statement | Debit (-) | Interest Expense |
93
+ | Tax | Income Statement | Debit (-) | Income Tax |
94
+ | Asset | Balance Sheet | Debit (+) | Cash, AR, Inventory |
95
+ | Liability | Balance Sheet | Credit (-) | AP, Debt |
96
+ | Equity | Balance Sheet | Credit (-) | Retained Earnings |
97
+
98
+ ### Scenarios
99
+
100
+ | ScenarioName | ScenarioType | IsActual | Purpose |
101
+ |--------------|--------------|----------|---------|
102
+ | Actual | Actual | TRUE | Recorded transactions |
103
+ | Budget | Budget | FALSE | Annual plan |
104
+ | Forecast | Forecast | FALSE | Rolling forecast |
105
+ | Prior Year | Actual | TRUE | Comparison baseline |
106
+
107
+ ---
108
+
109
+ ## Key Measures
110
+
111
+ ### Base Measures
112
+
113
+ ```dax
114
+ // Actuals only
115
+ Actual Amount =
116
+ CALCULATE(
117
+ SUM(FactFinancials[Amount]),
118
+ DimScenario[IsActual] = TRUE()
119
+ )
120
+
121
+ // Budget only
122
+ Budget Amount =
123
+ CALCULATE(
124
+ SUM(FactFinancials[Amount]),
125
+ DimScenario[ScenarioName] = "Budget"
126
+ )
127
+
128
+ // Forecast only
129
+ Forecast Amount =
130
+ CALCULATE(
131
+ SUM(FactFinancials[Amount]),
132
+ DimScenario[ScenarioName] = "Forecast"
133
+ )
134
+ ```
135
+
136
+ ### Income Statement Measures
137
+
138
+ ```dax
139
+ // Revenue (positive = good)
140
+ Revenue =
141
+ CALCULATE(
142
+ [Actual Amount],
143
+ DimAccount[AccountType] = "Revenue"
144
+ )
145
+
146
+ // Gross Profit
147
+ Gross Profit =
148
+ [Revenue] + CALCULATE([Actual Amount], DimAccount[AccountType] = "COGS")
149
+
150
+ // Gross Margin %
151
+ Gross Margin % =
152
+ DIVIDE([Gross Profit], [Revenue])
153
+
154
+ // Operating Expenses
155
+ OpEx =
156
+ CALCULATE(
157
+ [Actual Amount],
158
+ DimAccount[AccountType] = "OpEx"
159
+ )
160
+
161
+ // EBITDA
162
+ EBITDA =
163
+ [Gross Profit] + [OpEx]
164
+
165
+ // Net Income
166
+ Net Income =
167
+ CALCULATE(
168
+ [Actual Amount],
169
+ DimAccount[FinancialStmt] = "Income Statement"
170
+ )
171
+ ```
172
+
173
+ ### Variance Analysis
174
+
175
+ ```dax
176
+ // Budget Variance (Actual - Budget)
177
+ Budget Variance =
178
+ [Actual Amount] - [Budget Amount]
179
+
180
+ // Budget Variance %
181
+ Budget Variance % =
182
+ DIVIDE([Budget Variance], ABS([Budget Amount]))
183
+
184
+ // Favorable/Unfavorable indicator
185
+ Variance Status =
186
+ VAR _Variance = [Budget Variance]
187
+ VAR _AccountType = SELECTEDVALUE(DimAccount[AccountType])
188
+ VAR _IsExpense = _AccountType IN {"COGS", "OpEx", "OtherExpense", "Tax"}
189
+ RETURN
190
+ SWITCH(
191
+ TRUE(),
192
+ ISBLANK(_Variance), BLANK(),
193
+ _IsExpense && _Variance < 0, "Favorable",
194
+ _IsExpense && _Variance > 0, "Unfavorable",
195
+ NOT _IsExpense && _Variance > 0, "Favorable",
196
+ "Unfavorable"
197
+ )
198
+ ```
199
+
200
+ ### YTD and Period Comparisons
201
+
202
+ ```dax
203
+ // Year-to-Date Actual
204
+ Actual YTD =
205
+ TOTALYTD([Actual Amount], DimDate[Date])
206
+
207
+ // Prior Year Same Period
208
+ Actual PY =
209
+ CALCULATE(
210
+ [Actual Amount],
211
+ SAMEPERIODLASTYEAR(DimDate[Date])
212
+ )
213
+
214
+ // Prior Year YTD
215
+ Actual YTD PY =
216
+ CALCULATE(
217
+ [Actual YTD],
218
+ SAMEPERIODLASTYEAR(DimDate[Date])
219
+ )
220
+
221
+ // YoY Growth %
222
+ YoY Growth % =
223
+ DIVIDE([Actual Amount] - [Actual PY], ABS([Actual PY]))
224
+ ```
225
+
226
+ See [measures.dax](./measures.dax) for the complete measure library (50+ measures).
227
+
228
+ ---
229
+
230
+ ## Report Pages
231
+
232
+ ### 1. Executive Summary
233
+
234
+ | Visual | Content |
235
+ |--------|---------|
236
+ | KPI Cards | Revenue, Net Income, EBITDA with YoY % |
237
+ | Waterfall | Revenue to Net Income bridge |
238
+ | Line Chart | Monthly trend vs Prior Year |
239
+ | Table | Key metrics by Quarter |
240
+
241
+ ### 2. P&L Statement
242
+
243
+ | Visual | Content |
244
+ |--------|---------|
245
+ | Matrix | Full P&L with hierarchy (Account Group > Account) |
246
+ | Columns | Actual, Budget, Variance, Variance %, PY |
247
+ | Conditional | Red/Green variance highlighting |
248
+ | Drill-through | To account detail page |
249
+
250
+ ### 3. Variance Analysis
251
+
252
+ | Visual | Content |
253
+ |--------|---------|
254
+ | Decomposition Tree | Variance drivers by dimension |
255
+ | Scatter Plot | Budget vs Actual by Cost Center |
256
+ | Table | Top 10 variances with explanations |
257
+ | Bar Chart | Variance by Department |
258
+
259
+ ### 4. Balance Sheet
260
+
261
+ | Visual | Content |
262
+ |--------|---------|
263
+ | Matrix | Assets, Liabilities, Equity structure |
264
+ | KPI Cards | Current Ratio, Quick Ratio, Debt/Equity |
265
+ | Waterfall | Change in Cash position |
266
+
267
+ ### 5. Cash Flow
268
+
269
+ | Visual | Content |
270
+ |--------|---------|
271
+ | Waterfall | Operating, Investing, Financing flows |
272
+ | Line Chart | Cash balance trend |
273
+ | Table | Cash sources and uses |
274
+
275
+ ---
276
+
277
+ ## Financial Ratios
278
+
279
+ ```dax
280
+ // Profitability
281
+ Gross Margin % = DIVIDE([Gross Profit], [Revenue])
282
+ Operating Margin % = DIVIDE([EBITDA], [Revenue])
283
+ Net Margin % = DIVIDE([Net Income], [Revenue])
284
+ ROE = DIVIDE([Net Income TTM], [Total Equity])
285
+ ROA = DIVIDE([Net Income TTM], [Total Assets])
286
+
287
+ // Liquidity
288
+ Current Ratio = DIVIDE([Current Assets], [Current Liabilities])
289
+ Quick Ratio = DIVIDE([Current Assets] - [Inventory], [Current Liabilities])
290
+ Cash Ratio = DIVIDE([Cash], [Current Liabilities])
291
+
292
+ // Leverage
293
+ Debt to Equity = DIVIDE([Total Debt], [Total Equity])
294
+ Debt to Assets = DIVIDE([Total Debt], [Total Assets])
295
+ Interest Coverage = DIVIDE([EBITDA], [Interest Expense])
296
+
297
+ // Efficiency
298
+ Days Sales Outstanding = DIVIDE([Accounts Receivable], [Revenue]) * 365
299
+ Days Payable Outstanding = DIVIDE([Accounts Payable], [COGS]) * 365
300
+ Inventory Turnover = DIVIDE([COGS], [Average Inventory])
301
+ ```
302
+
303
+ ---
304
+
305
+ ## Implementation Checklist
306
+
307
+ ### Data Model
308
+ - [ ] Create DimDate with fiscal calendar attributes
309
+ - [ ] Create DimAccount with proper hierarchy and signs
310
+ - [ ] Create DimCostCenter with department/division structure
311
+ - [ ] Create DimScenario for Actual/Budget/Forecast
312
+ - [ ] Load FactFinancials with all scenario data
313
+ - [ ] Set up relationships
314
+ - [ ] Mark DimDate as Date Table
315
+
316
+ ### Measures
317
+ - [ ] Create base measures (Actual, Budget, Forecast)
318
+ - [ ] Create P&L subtotals (Revenue, Gross Profit, EBITDA, Net Income)
319
+ - [ ] Create variance measures with favorable/unfavorable logic
320
+ - [ ] Create time intelligence (YTD, PY, YoY)
321
+ - [ ] Create financial ratios
322
+ - [ ] Organize in display folders
323
+
324
+ ### Reports
325
+ - [ ] Executive Summary page
326
+ - [ ] P&L Statement with drill-through
327
+ - [ ] Variance Analysis with decomposition
328
+ - [ ] Balance Sheet snapshot
329
+ - [ ] Cash Flow statement
330
+ - [ ] Apply theme and formatting
331
+
332
+ ---
333
+
334
+ ## Files in This Example
335
+
336
+ | File | Description |
337
+ |------|-------------|
338
+ | [README.md](./README.md) | This overview |
339
+ | [data-model.md](./data-model.md) | Complete table definitions |
340
+ | [measures.dax](./measures.dax) | 50+ DAX measures |
341
+
342
+ ---
343
+
344
+ ## Tips for Financial Reporting
345
+
346
+ 1. **Sign conventions matter** - Use NaturalSign to handle debit/credit properly
347
+ 2. **Fiscal vs calendar** - Finance always uses fiscal periods
348
+ 3. **Variance coloring** - Favorable expenses (under budget) should be green even if negative
349
+ 4. **YTD resets** - Use fiscal year start date in TOTALYTD
350
+ 5. **Balance sheet** - Point-in-time, not period aggregations
351
+ 6. **Drill-through** - Essential for explaining variances