@luquimbo/bi-superpowers 3.1.1 → 3.2.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 (107) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.claude-plugin/skill-manifest.json +1 -1
  4. package/.plugin/plugin.json +1 -1
  5. package/bin/build-plugin.js +6 -6
  6. package/bin/cli.js +169 -310
  7. package/bin/commands/install.js +87 -70
  8. package/bin/lib/agents.js +19 -0
  9. package/bin/lib/mcp-config.js +23 -4
  10. package/desktop-extension/manifest.json +4 -11
  11. package/desktop-extension/server.js +34 -25
  12. package/package.json +3 -9
  13. package/skills/pbi-connect/SKILL.md +1 -1
  14. package/skills/project-kickoff/SKILL.md +1 -1
  15. package/bin/commands/add.js +0 -533
  16. package/bin/commands/add.test.js +0 -77
  17. package/bin/commands/changelog.js +0 -443
  18. package/bin/commands/pull.js +0 -287
  19. package/bin/commands/pull.test.js +0 -36
  20. package/bin/commands/push.js +0 -231
  21. package/bin/commands/push.test.js +0 -14
  22. package/bin/commands/search.js +0 -344
  23. package/bin/commands/search.test.js +0 -115
  24. package/bin/commands/setup.js +0 -545
  25. package/bin/commands/setup.test.js +0 -46
  26. package/bin/commands/sync-profile.js +0 -405
  27. package/bin/commands/sync-profile.test.js +0 -14
  28. package/bin/commands/sync-source.js +0 -418
  29. package/bin/commands/sync-source.test.js +0 -14
  30. package/bin/utils/errors.js +0 -159
  31. package/bin/utils/git.js +0 -298
  32. package/bin/utils/logger.js +0 -142
  33. package/bin/utils/pbix.js +0 -305
  34. package/bin/utils/pbix.test.js +0 -37
  35. package/bin/utils/profiles.js +0 -312
  36. package/bin/utils/projects.js +0 -169
  37. package/bin/utils/readline.js +0 -206
  38. package/bin/utils/readline.test.js +0 -47
  39. package/docs/openrouter-free-models.md +0 -92
  40. package/library/examples/README.md +0 -151
  41. package/library/examples/finance-reporting/README.md +0 -351
  42. package/library/examples/finance-reporting/data-model.md +0 -267
  43. package/library/examples/finance-reporting/measures.dax +0 -557
  44. package/library/examples/hr-analytics/README.md +0 -371
  45. package/library/examples/hr-analytics/data-model.md +0 -315
  46. package/library/examples/hr-analytics/measures.dax +0 -460
  47. package/library/examples/marketing-analytics/README.md +0 -37
  48. package/library/examples/marketing-analytics/data-model.md +0 -62
  49. package/library/examples/marketing-analytics/measures.dax +0 -110
  50. package/library/examples/retail-analytics/README.md +0 -439
  51. package/library/examples/retail-analytics/data-model.md +0 -288
  52. package/library/examples/retail-analytics/measures.dax +0 -481
  53. package/library/examples/supply-chain/README.md +0 -37
  54. package/library/examples/supply-chain/data-model.md +0 -69
  55. package/library/examples/supply-chain/measures.dax +0 -77
  56. package/library/examples/udf-library/README.md +0 -228
  57. package/library/examples/udf-library/functions.dax +0 -571
  58. package/library/snippets/dax/README.md +0 -292
  59. package/library/snippets/dax/business-domains.md +0 -576
  60. package/library/snippets/dax/calculate-patterns.md +0 -276
  61. package/library/snippets/dax/calculation-groups.md +0 -489
  62. package/library/snippets/dax/error-handling.md +0 -495
  63. package/library/snippets/dax/iterators-and-aggregations.md +0 -474
  64. package/library/snippets/dax/kpis-and-metrics.md +0 -293
  65. package/library/snippets/dax/rankings-and-topn.md +0 -235
  66. package/library/snippets/dax/security-patterns.md +0 -413
  67. package/library/snippets/dax/text-and-formatting.md +0 -316
  68. package/library/snippets/dax/time-intelligence.md +0 -196
  69. package/library/snippets/dax/user-defined-functions.md +0 -477
  70. package/library/snippets/dax/virtual-tables.md +0 -546
  71. package/library/snippets/excel-formulas/README.md +0 -84
  72. package/library/snippets/excel-formulas/aggregations.md +0 -330
  73. package/library/snippets/excel-formulas/dates-and-times.md +0 -361
  74. package/library/snippets/excel-formulas/dynamic-arrays.md +0 -314
  75. package/library/snippets/excel-formulas/lookups.md +0 -169
  76. package/library/snippets/excel-formulas/text-functions.md +0 -363
  77. package/library/snippets/governance/naming-conventions.md +0 -97
  78. package/library/snippets/governance/review-checklists.md +0 -107
  79. package/library/snippets/power-query/README.md +0 -389
  80. package/library/snippets/power-query/api-integration.md +0 -707
  81. package/library/snippets/power-query/connections.md +0 -434
  82. package/library/snippets/power-query/data-cleaning.md +0 -298
  83. package/library/snippets/power-query/error-handling.md +0 -526
  84. package/library/snippets/power-query/parameters.md +0 -350
  85. package/library/snippets/power-query/performance.md +0 -506
  86. package/library/snippets/power-query/transformations.md +0 -330
  87. package/library/snippets/report-design/accessibility.md +0 -78
  88. package/library/snippets/report-design/chart-selection.md +0 -54
  89. package/library/snippets/report-design/layout-patterns.md +0 -87
  90. package/library/templates/data-models/README.md +0 -93
  91. package/library/templates/data-models/finance-model.md +0 -627
  92. package/library/templates/data-models/retail-star-schema.md +0 -473
  93. package/library/templates/excel/README.md +0 -83
  94. package/library/templates/excel/budget-tracker.md +0 -432
  95. package/library/templates/excel/data-entry-form.md +0 -533
  96. package/library/templates/power-bi/README.md +0 -72
  97. package/library/templates/power-bi/finance-report.md +0 -449
  98. package/library/templates/power-bi/kpi-scorecard.md +0 -461
  99. package/library/templates/power-bi/sales-dashboard.md +0 -281
  100. package/library/themes/excel/README.md +0 -436
  101. package/library/themes/power-bi/README.md +0 -271
  102. package/library/themes/power-bi/accessible.json +0 -307
  103. package/library/themes/power-bi/bi-superpowers-default.json +0 -858
  104. package/library/themes/power-bi/corporate-blue.json +0 -291
  105. package/library/themes/power-bi/dark-mode.json +0 -291
  106. package/library/themes/power-bi/minimal.json +0 -292
  107. package/library/themes/power-bi/print-friendly.json +0 -309
@@ -1,627 +0,0 @@
1
- # Finance Data Model
2
-
3
- ## Overview
4
-
5
- A comprehensive semantic model for financial reporting, budgeting, and analysis. Designed to support P&L statements, balance sheets, cash flow analysis, and budget variance tracking with proper account hierarchy handling.
6
-
7
- ---
8
-
9
- ## Business Context
10
-
11
- ### Key Business Questions
12
-
13
- 1. **Profit & Loss**
14
- - What is revenue, COGS, and net income by period?
15
- - How do expenses trend over time?
16
- - What is the margin by product line or department?
17
-
18
- 2. **Budget Analysis**
19
- - How do actuals compare to budget?
20
- - What are the key variance drivers?
21
- - What is the forecast for year-end?
22
-
23
- 3. **Balance Sheet**
24
- - What are current assets and liabilities?
25
- - How has working capital changed?
26
- - What is the debt-to-equity ratio?
27
-
28
- 4. **Cash Flow**
29
- - What is cash from operations?
30
- - How much was invested in CapEx?
31
- - What is the cash runway?
32
-
33
- ---
34
-
35
- ## Schema Diagram
36
-
37
- ```
38
- ┌─────────────┐
39
- │ DimDate │
40
- │─────────────│
41
- │ DateKey (PK)│
42
- │ Date │
43
- │ FiscalYear │
44
- │ FiscalPeriod│
45
- │ IsActual │
46
- └──────┬──────┘
47
-
48
- │ 1:M
49
-
50
- ┌─────────────┐ ┌──────┴──────┐ ┌─────────────┐
51
- │ DimAccount │ │ FactGL │ │DimScenario │
52
- │─────────────│ │─────────────│ │─────────────│
53
- │AccountKey PK│────>│ GLKey (PK) │<────│ScenarioKey │
54
- │ AccountID │ M:1 │ DateKey (FK)│ 1:M │ ScenarioID │
55
- │ AccountName │ │AccountKey FK│ │ScenarioName │
56
- │ AccountType │ │ScenarioKey │ │ ScenarioType│
57
- │ AccountGroup│ │CostCenterKey│ └─────────────┘
58
- │ ParentAcct │ │ EntityKey FK│
59
- │ L1-L5 Hier │ │ Debit │ ┌─────────────┐
60
- │ IsPL/IsBS │ │ Credit │ │DimCostCenter│
61
- │ SignConv │ │ Amount │ │─────────────│
62
- └─────────────┘ └──────┬──────┘ │CostCenterKey│
63
- │ │CostCenterID │
64
- ┌────────────────┘ │ Name │
65
- │ │ Department │
66
- │ M:1 │ Division │
67
- ▼ │ Manager │
68
- ┌─────────────┐ └─────────────┘
69
- │ DimEntity │
70
- │─────────────│ ┌─────────────┐
71
- │EntityKey PK │ │ FactBudget │
72
- │ EntityID │ │─────────────│
73
- │ EntityName │ │ BudgetKey │
74
- │ Currency │ │ DateKey │
75
- │ ParentEntity│ │ AccountKey │
76
- │ IsElim │ │CostCenterKey│
77
- └─────────────┘ │ ScenarioKey │
78
- │ Amount │
79
- └─────────────┘
80
- ```
81
-
82
- ---
83
-
84
- ## Dimension Tables
85
-
86
- ### DimDate (Financial Calendar)
87
-
88
- **Purpose:** Fiscal calendar with period close tracking
89
-
90
- | Column | Data Type | Description | Sample Values |
91
- |--------|-----------|-------------|---------------|
92
- | DateKey | INT | Surrogate key (YYYYMMDD) | 20240115 |
93
- | Date | DATE | Full date | 2024-01-15 |
94
- | CalendarYear | INT | Calendar year | 2024 |
95
- | CalendarMonth | INT | Calendar month | 1 |
96
- | CalendarQuarter | INT | Calendar quarter | 1 |
97
- | FiscalYear | INT | Fiscal year | 2024 |
98
- | FiscalPeriod | INT | Fiscal period (1-12 or 1-13) | 7 |
99
- | FiscalQuarter | INT | Fiscal quarter | 3 |
100
- | FiscalYearMonth | VARCHAR(10) | FY-Period label | FY24-P07 |
101
- | PeriodStartDate | DATE | First day of period | 2024-01-01 |
102
- | PeriodEndDate | DATE | Last day of period | 2024-01-31 |
103
- | IsActualPeriod | BIT | Has actual data | 1 |
104
- | IsClosed | BIT | Period is closed | 1 |
105
- | DaysInPeriod | INT | Days in fiscal period | 31 |
106
- | IsYearEnd | BIT | Year-end period | 0 |
107
-
108
- ### DimAccount (Chart of Accounts)
109
-
110
- **Purpose:** Account hierarchy with financial statement mapping
111
-
112
- | Column | Data Type | Description | Sample Values |
113
- |--------|-----------|-------------|---------------|
114
- | AccountKey | INT | Surrogate key | 1001 |
115
- | AccountID | VARCHAR(20) | GL account number | 4010 |
116
- | AccountName | VARCHAR(100) | Account name | Product Revenue |
117
- | AccountDescription | VARCHAR(500) | Full description | Revenue from product sales |
118
- | AccountType | VARCHAR(30) | High-level type | Revenue |
119
- | AccountGroup | VARCHAR(50) | Grouping | Operating Revenue |
120
- | AccountClass | VARCHAR(30) | Class | Income Statement |
121
- | StatementLine | VARCHAR(50) | Financial statement line | Net Revenue |
122
- | L1_Category | VARCHAR(50) | Hierarchy Level 1 | Income Statement |
123
- | L2_Category | VARCHAR(50) | Hierarchy Level 2 | Revenue |
124
- | L3_Category | VARCHAR(50) | Hierarchy Level 3 | Operating Revenue |
125
- | L4_Category | VARCHAR(50) | Hierarchy Level 4 | Product Revenue |
126
- | L5_Account | VARCHAR(100) | Hierarchy Level 5 (Detail) | Product Revenue - Domestic |
127
- | ParentAccountKey | INT | Parent in hierarchy | 1000 |
128
- | IsBS | BIT | Balance Sheet account | 0 |
129
- | IsPL | BIT | P&L account | 1 |
130
- | IsCF | BIT | Cash Flow relevant | 0 |
131
- | NormalBalance | VARCHAR(10) | Debit or Credit | Credit |
132
- | SignConvention | INT | Sign for reporting (+1/-1) | -1 |
133
- | SortOrder | INT | Display order | 100 |
134
- | IsActive | BIT | Active account | 1 |
135
- | IsPostable | BIT | Can receive postings | 1 |
136
-
137
- **Account Types:**
138
- ```
139
- Balance Sheet (IsBS = 1):
140
- - Asset
141
- - Liability
142
- - Equity
143
-
144
- Income Statement (IsPL = 1):
145
- - Revenue
146
- - COGS
147
- - Operating Expense
148
- - Other Income/Expense
149
- - Tax
150
- ```
151
-
152
- **Sign Convention:**
153
- ```
154
- Revenue accounts: SignConvention = -1
155
- (Credit balance shows as positive)
156
-
157
- Expense accounts: SignConvention = 1
158
- (Debit balance shows as positive)
159
-
160
- Asset accounts: SignConvention = 1
161
- (Debit balance shows as positive)
162
-
163
- Liability/Equity: SignConvention = -1
164
- (Credit balance shows as positive)
165
- ```
166
-
167
- ### DimScenario (Scenario Dimension)
168
-
169
- **Purpose:** Actual, Budget, Forecast versions
170
-
171
- | Column | Data Type | Description | Sample Values |
172
- |--------|-----------|-------------|---------------|
173
- | ScenarioKey | INT | Surrogate key | 1 |
174
- | ScenarioID | VARCHAR(20) | Scenario code | ACT |
175
- | ScenarioName | VARCHAR(50) | Display name | Actual |
176
- | ScenarioType | VARCHAR(30) | Type classification | Actual |
177
- | IsActual | BIT | Actual data flag | 1 |
178
- | IsBudget | BIT | Budget version flag | 0 |
179
- | IsForecast | BIT | Forecast version flag | 0 |
180
- | FiscalYear | INT | Applicable year | 2024 |
181
- | Version | VARCHAR(20) | Version number | v1.0 |
182
- | ApprovedDate | DATE | Approval date | 2023-12-15 |
183
- | IsActive | BIT | Current/active | 1 |
184
-
185
- **Common Scenarios:**
186
- ```
187
- 1. Actual (ACT) - Recorded transactions
188
- 2. Budget (BUD) - Annual approved budget
189
- 3. Forecast (FC1, FC2, FC3) - Quarterly reforecasts
190
- 4. Prior Year (PY) - Last year actuals
191
- 5. Plan (PLN) - Long-term plan
192
- ```
193
-
194
- ### DimCostCenter (Cost Center Dimension)
195
-
196
- **Purpose:** Organizational hierarchy for expenses
197
-
198
- | Column | Data Type | Description | Sample Values |
199
- |--------|-----------|-------------|---------------|
200
- | CostCenterKey | INT | Surrogate key | 501 |
201
- | CostCenterID | VARCHAR(20) | Cost center code | CC-100 |
202
- | CostCenterName | VARCHAR(100) | Name | Engineering |
203
- | Department | VARCHAR(50) | Department | Technology |
204
- | Division | VARCHAR(50) | Division | Product |
205
- | BusinessUnit | VARCHAR(50) | Business unit | Software |
206
- | ManagerName | VARCHAR(100) | Responsible manager | John Smith |
207
- | ManagerEmail | VARCHAR(100) | Manager email | john.smith@company.com |
208
- | ParentCostCenterKey | INT | Parent in hierarchy | 500 |
209
- | L1_Division | VARCHAR(50) | Hierarchy Level 1 | Product |
210
- | L2_Department | VARCHAR(50) | Hierarchy Level 2 | Technology |
211
- | L3_CostCenter | VARCHAR(50) | Hierarchy Level 3 | Engineering |
212
- | IsActive | BIT | Active cost center | 1 |
213
-
214
- ### DimEntity (Legal Entity Dimension)
215
-
216
- **Purpose:** Multi-company consolidation
217
-
218
- | Column | Data Type | Description | Sample Values |
219
- |--------|-----------|-------------|---------------|
220
- | EntityKey | INT | Surrogate key | 1 |
221
- | EntityID | VARCHAR(20) | Entity code | US01 |
222
- | EntityName | VARCHAR(100) | Legal name | Company USA Inc. |
223
- | ShortName | VARCHAR(50) | Short name | USA |
224
- | Currency | VARCHAR(3) | Local currency | USD |
225
- | Country | VARCHAR(50) | Country | United States |
226
- | Region | VARCHAR(30) | Region | Americas |
227
- | EntityType | VARCHAR(30) | Type | Operating |
228
- | ParentEntityKey | INT | Parent entity | NULL |
229
- | ConsolidationPct | DECIMAL(5,2) | Ownership % | 100.00 |
230
- | IsElimination | BIT | Elimination entity | 0 |
231
- | IsConsolidated | BIT | Include in consolidation | 1 |
232
- | IsActive | BIT | Active entity | 1 |
233
-
234
- ---
235
-
236
- ## Fact Tables
237
-
238
- ### FactGL (General Ledger)
239
-
240
- **Purpose:** Journal entry level detail
241
-
242
- | Column | Data Type | Description | Grain |
243
- |--------|-----------|-------------|-------|
244
- | GLKey | BIGINT | Surrogate key | One row per journal line |
245
- | DateKey | INT | Transaction date (FK) | |
246
- | AccountKey | INT | GL Account (FK) | |
247
- | ScenarioKey | INT | Scenario (FK) | |
248
- | CostCenterKey | INT | Cost Center (FK) | |
249
- | EntityKey | INT | Legal Entity (FK) | |
250
- | JournalID | VARCHAR(30) | Journal entry ID | |
251
- | LineNumber | INT | Line in journal | |
252
- | Debit | DECIMAL(18,2) | Debit amount | |
253
- | Credit | DECIMAL(18,2) | Credit amount | |
254
- | Amount | DECIMAL(18,2) | Net amount (Debit - Credit) | |
255
- | LocalAmount | DECIMAL(18,2) | Amount in local currency | |
256
- | FXRate | DECIMAL(12,6) | Exchange rate | |
257
- | Description | VARCHAR(500) | Transaction description | |
258
- | Reference | VARCHAR(50) | External reference | |
259
- | PostedBy | VARCHAR(50) | User who posted | |
260
- | PostedDate | DATETIME | Posting timestamp | |
261
-
262
- ### FactBudget (Budget/Forecast)
263
-
264
- **Purpose:** Budget and forecast data at summary level
265
-
266
- | Column | Data Type | Description | Grain |
267
- |--------|-----------|-------------|-------|
268
- | BudgetKey | BIGINT | Surrogate key | One row per account/CC/period |
269
- | DateKey | INT | Period start date (FK) | |
270
- | AccountKey | INT | GL Account (FK) | |
271
- | ScenarioKey | INT | Scenario (FK) | |
272
- | CostCenterKey | INT | Cost Center (FK) | |
273
- | EntityKey | INT | Legal Entity (FK) | |
274
- | Amount | DECIMAL(18,2) | Budget amount | |
275
- | Units | INT | Budget units (optional) | |
276
- | Notes | VARCHAR(500) | Budget assumptions | |
277
- | VersionDate | DATE | Version date | |
278
-
279
- ### FactBalance (Balance Sheet Snapshots - Optional)
280
-
281
- **Purpose:** Period-end balances for BS accounts
282
-
283
- | Column | Data Type | Description | Grain |
284
- |--------|-----------|-------------|-------|
285
- | BalanceKey | BIGINT | Surrogate key | One row per account/entity/period |
286
- | DateKey | INT | Period end date (FK) | |
287
- | AccountKey | INT | GL Account (FK) | |
288
- | EntityKey | INT | Legal Entity (FK) | |
289
- | ScenarioKey | INT | Scenario (FK) | |
290
- | BeginningBalance | DECIMAL(18,2) | Opening balance | |
291
- | Activity | DECIMAL(18,2) | Period activity | |
292
- | EndingBalance | DECIMAL(18,2) | Closing balance | |
293
-
294
- ---
295
-
296
- ## Recommended DAX Measures
297
-
298
- ### Core Financial Measures
299
-
300
- ```dax
301
- // Amount with Sign Convention
302
- Amount =
303
- SUMX(
304
- FactGL,
305
- FactGL[Amount] * RELATED(DimAccount[SignConvention])
306
- )
307
-
308
- // Or simpler if Amount already signed correctly
309
- Total Amount =
310
- SUM(FactGL[Amount])
311
-
312
- // Revenue
313
- Revenue =
314
- CALCULATE(
315
- [Amount],
316
- DimAccount[AccountType] = "Revenue"
317
- )
318
-
319
- // COGS
320
- COGS =
321
- CALCULATE(
322
- [Amount],
323
- DimAccount[AccountType] = "COGS"
324
- )
325
-
326
- // Gross Profit
327
- Gross Profit =
328
- [Revenue] - [COGS]
329
-
330
- // Gross Margin %
331
- Gross Margin % =
332
- DIVIDE([Gross Profit], [Revenue])
333
-
334
- // Operating Expenses
335
- Operating Expenses =
336
- CALCULATE(
337
- [Amount],
338
- DimAccount[AccountType] = "Operating Expense"
339
- )
340
-
341
- // EBITDA
342
- EBITDA =
343
- [Gross Profit] - [Operating Expenses] + [Depreciation & Amortization]
344
-
345
- // Net Income
346
- Net Income =
347
- CALCULATE(
348
- [Amount],
349
- DimAccount[IsPL] = TRUE
350
- )
351
- ```
352
-
353
- ### Budget Variance
354
-
355
- ```dax
356
- // Budget Amount
357
- Budget Amount =
358
- CALCULATE(
359
- [Amount],
360
- DimScenario[ScenarioName] = "Budget"
361
- )
362
-
363
- // Actual Amount
364
- Actual Amount =
365
- CALCULATE(
366
- [Amount],
367
- DimScenario[ScenarioName] = "Actual"
368
- )
369
-
370
- // Variance
371
- Variance $ =
372
- [Actual Amount] - [Budget Amount]
373
-
374
- // Variance % (context-aware)
375
- Variance % =
376
- VAR _Actual = [Actual Amount]
377
- VAR _Budget = [Budget Amount]
378
- VAR _AccountType = SELECTEDVALUE(DimAccount[AccountType])
379
- VAR _IsExpense = _AccountType IN {"COGS", "Operating Expense", "Other Expense"}
380
- RETURN
381
- IF(
382
- _IsExpense,
383
- DIVIDE(_Budget - _Actual, ABS(_Budget)), // Under budget is positive
384
- DIVIDE(_Actual - _Budget, ABS(_Budget)) // Over revenue is positive
385
- )
386
-
387
- // Variance Status
388
- Variance Status =
389
- VAR _Var = [Variance %]
390
- RETURN
391
- SWITCH(
392
- TRUE(),
393
- _Var >= 0, "Favorable",
394
- _Var >= -0.05, "On Track",
395
- _Var >= -0.10, "At Risk",
396
- "Unfavorable"
397
- )
398
- ```
399
-
400
- ### Period Intelligence
401
-
402
- ```dax
403
- // YTD Amount
404
- YTD Amount =
405
- TOTALYTD(
406
- [Amount],
407
- DimDate[Date],
408
- "6/30" // Fiscal year end if not Dec 31
409
- )
410
-
411
- // Prior Year
412
- Prior Year =
413
- CALCULATE(
414
- [Amount],
415
- SAMEPERIODLASTYEAR(DimDate[Date])
416
- )
417
-
418
- // YoY Change
419
- YoY Change =
420
- [Amount] - [Prior Year]
421
-
422
- // YoY %
423
- YoY % =
424
- DIVIDE([YoY Change], ABS([Prior Year]))
425
-
426
- // MTD
427
- MTD Amount =
428
- TOTALMTD([Amount], DimDate[Date])
429
-
430
- // Full Year Run Rate
431
- Full Year Run Rate =
432
- VAR _YTD = [YTD Amount]
433
- VAR _MonthsElapsed = DISTINCTCOUNT(DimDate[FiscalPeriod])
434
- RETURN
435
- DIVIDE(_YTD * 12, _MonthsElapsed)
436
- ```
437
-
438
- ### Balance Sheet Measures
439
-
440
- ```dax
441
- // Ending Balance (cumulative for BS)
442
- Ending Balance =
443
- CALCULATE(
444
- [Amount],
445
- FILTER(
446
- ALL(DimDate),
447
- DimDate[Date] <= MAX(DimDate[Date])
448
- ),
449
- DimAccount[IsBS] = TRUE
450
- )
451
-
452
- // Current Assets
453
- Current Assets =
454
- CALCULATE(
455
- [Ending Balance],
456
- DimAccount[AccountGroup] = "Current Assets"
457
- )
458
-
459
- // Current Liabilities
460
- Current Liabilities =
461
- CALCULATE(
462
- [Ending Balance],
463
- DimAccount[AccountGroup] = "Current Liabilities"
464
- )
465
-
466
- // Working Capital
467
- Working Capital =
468
- [Current Assets] + [Current Liabilities] // Liabilities are negative
469
-
470
- // Current Ratio
471
- Current Ratio =
472
- DIVIDE([Current Assets], ABS([Current Liabilities]))
473
- ```
474
-
475
- ### Financial Ratios
476
-
477
- ```dax
478
- // Operating Margin
479
- Operating Margin =
480
- DIVIDE([EBITDA], [Revenue])
481
-
482
- // Return on Assets
483
- ROA =
484
- DIVIDE(
485
- [Net Income],
486
- CALCULATE([Ending Balance], DimAccount[AccountType] = "Asset")
487
- )
488
-
489
- // Debt to Equity
490
- Debt to Equity =
491
- DIVIDE(
492
- CALCULATE([Ending Balance], DimAccount[AccountType] = "Liability"),
493
- CALCULATE([Ending Balance], DimAccount[AccountType] = "Equity")
494
- )
495
- ```
496
-
497
- ---
498
-
499
- ## P&L Structure
500
-
501
- ### Standard P&L Order
502
-
503
- ```
504
- Revenue
505
- Product Revenue
506
- Service Revenue
507
- Other Revenue
508
- ─────────────────────
509
- Total Revenue
510
-
511
- Cost of Goods Sold
512
- Direct Materials
513
- Direct Labor
514
- Manufacturing Overhead
515
- ─────────────────────
516
- Total COGS
517
-
518
- GROSS PROFIT
519
-
520
- Operating Expenses
521
- Sales & Marketing
522
- Salaries - Sales
523
- Advertising
524
- Travel - Sales
525
- Research & Development
526
- Salaries - R&D
527
- Software & Tools
528
- General & Administrative
529
- Executive Salaries
530
- Legal & Professional
531
- Rent & Facilities
532
- Insurance
533
- Depreciation
534
- ─────────────────────
535
- Total Operating Expenses
536
-
537
- OPERATING INCOME (EBIT)
538
-
539
- Other Income/Expense
540
- Interest Income
541
- Interest Expense
542
- FX Gains/Losses
543
- Other
544
- ─────────────────────
545
- Total Other
546
-
547
- INCOME BEFORE TAX
548
-
549
- Income Tax Expense
550
- ─────────────────────
551
- NET INCOME
552
- ```
553
-
554
- ### DAX for P&L Matrix
555
-
556
- ```dax
557
- // Sort Order for P&L display
558
- P&L Sort =
559
- SELECTEDVALUE(DimAccount[SortOrder])
560
-
561
- // P&L Amount with proper aggregation
562
- P&L Amount =
563
- IF(
564
- HASONEVALUE(DimAccount[L5_Account]),
565
- [Amount],
566
- SUMX(
567
- SUMMARIZE(DimAccount, DimAccount[L5_Account]),
568
- [Amount]
569
- )
570
- )
571
- ```
572
-
573
- ---
574
-
575
- ## Security Considerations
576
-
577
- ### Row-Level Security
578
-
579
- ```dax
580
- // Cost Center RLS
581
- [CostCenterAccess] =
582
- VAR _UserEmail = USERPRINCIPALNAME()
583
- VAR _UserCCs =
584
- CALCULATETABLE(
585
- VALUES(SecurityCostCenter[CostCenterKey]),
586
- SecurityCostCenter[UserEmail] = _UserEmail
587
- )
588
- RETURN
589
- DimCostCenter[CostCenterKey] IN _UserCCs
590
-
591
- // Entity RLS
592
- [EntityAccess] =
593
- VAR _UserEmail = USERPRINCIPALNAME()
594
- VAR _UserEntities =
595
- CALCULATETABLE(
596
- VALUES(SecurityEntity[EntityKey]),
597
- SecurityEntity[UserEmail] = _UserEmail
598
- )
599
- RETURN
600
- DimEntity[EntityKey] IN _UserEntities
601
- ```
602
-
603
- ---
604
-
605
- ## Implementation Checklist
606
-
607
- - [ ] Define fiscal calendar (year-end, periods)
608
- - [ ] Map Chart of Accounts with hierarchy levels
609
- - [ ] Set sign convention for each account type
610
- - [ ] Create scenario dimension with all versions
611
- - [ ] Build cost center hierarchy
612
- - [ ] Configure entity structure for consolidation
613
- - [ ] Load historical GL data
614
- - [ ] Import budget versions
615
- - [ ] Create core financial measures
616
- - [ ] Build variance calculations
617
- - [ ] Configure RLS for cost center/entity access
618
- - [ ] Test P&L, BS, and variance reports
619
- - [ ] Document calculation methodology
620
-
621
- ---
622
-
623
- ## Related Resources
624
-
625
- - [Finance Report Template](../power-bi/finance-report.md)
626
- - [DAX Patterns](../../snippets/dax/)
627
- - [Data Modeling Best Practices](../../skills/data-modeling/SKILL.md)