--- a/current-model.tmdl +++ b/current-model.tmdl @@ -172,7 +172,7 @@ lineageTag: a1b2c3d4-0005-0010-0000-000000000001 /// ============================================================ -/// MEASURES (existing — note: no gross margin measure exists) +/// MEASURES /// ============================================================ measure 'Total Sales' = @@ -193,18 +193,37 @@ DIVIDE([Total Sales], [Order Count], BLANK()) formatString: $#,##0.00 + measure 'Gross Profit' = + [Total Sales] - [Total Cost] + formatString: $#,##0 + description: Gross profit: total sales revenue minus total cost of goods sold + + measure 'Gross Margin %' = + DIVIDE([Gross Profit], [Total Sales], BLANK()) + formatString: 0.0% + description: Gross margin as a percentage of total sales revenue + measure 'Sales YTD' = TOTALYTD([Total Sales], 'Date'[Date]) formatString: $#,##0 + measure 'Customers by Region' = + CALCULATE( + DISTINCTCOUNT(Sales[CustomerKey]), + USERELATIONSHIP(Customer[RegionKey], Region[RegionKey]) + ) + formatString: #,##0 + description: Count of distinct customers using the Customer-Region relationship. Use this measure in visuals that need to show customers filtered by Region slicer. + /// ============================================================ /// RELATIONSHIPS /// ============================================================ -/// NOTE: The Region relationships below are configured with -/// BothDirections cross-filter. This was set up to allow a -/// Region slicer to filter Customer names, but it is causing -/// inconsistent region totals in the exec dashboard. +/// NOTE (2026-04-12): Region relationships fixed. Both were +/// bidirectional and caused ambiguous filter paths inflating totals. +/// Now: Sales→Region is OneDirection (active), Customer→Region is +/// OneDirection (inactive). See 'Customers by Region' measure for +/// Region→Customer slicer filtering via USERELATIONSHIP. relationship rel_Sales_Date fromColumn: Sales[DateKey] @@ -221,16 +240,21 @@ toColumn: Customer[CustomerKey] crossFilteringBehavior: OneDirection -/// PROBLEM: Bidirectional cross-filter causing ambiguous filter -/// propagation through Customer → Region path +/// FIX (2026-04-12): Changed from BothDirections to OneDirection. +/// Bidirectional cross-filter was causing ambiguous filter propagation +/// through Customer → Region path, inflating region totals. relationship rel_Sales_Region fromColumn: Sales[RegionKey] toColumn: Region[RegionKey] - crossFilteringBehavior: BothDirections - -/// PROBLEM: Second path from Region to Sales via Customer table -/// creates ambiguous filter propagation + crossFilteringBehavior: OneDirection + +/// FIX (2026-04-12): Changed from BothDirections to OneDirection AND +/// deactivated. This was a second active path from Region → Sales +/// (via Customer), creating ambiguous filter propagation that broke +/// region totals. Use USERELATIONSHIP in DAX measures that need +/// Region → Customer filtering (see 'Customers by Region' measure). relationship rel_Customer_Region fromColumn: Customer[RegionKey] toColumn: Region[RegionKey] - crossFilteringBehavior: BothDirections + crossFilteringBehavior: OneDirection + isActive: false