Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
I’m building a financial dashboard to allocate Amazon Operating Expenses (Advertising, FBA Fees, Storage, Inventory) by ASIN and Brand using purchase quantity as the allocation key.
I have the following tables and relationships:
Tables:
ASINMasterList (Dim_ASIN)
ItemKey (ASIN_SKU)
ASIN
SKU
Brand
Purchases
Purchase_ItemKey (ASIN_SKU)
Quantity
Date
Brand (lookup from Brand table)
FBA Revenue Report
SKU
Date
Amount (Amazon Operating Expense + Sales Revenue)
AccountType
DimDate
Date
YearMonth
Current Relationships:
ASINMasterList[ItemKey] → Purchases[Purchase_ItemKey] (active, single)
DimDate[Date] → Purchases[Date] (active)
DimDate[Date] → FBA Revenue Report[Date] (active)
Purchases[Brand] comes from a lookup to Brand table
No direct relationship between Brand table and other tables
My goal:
Allocate Amazon Operating Expenses to ASINs and roll up to Brand, proportional to purchase quantity, while keeping totals correct.
Current DAX attempt:
Issue:
Grand total of allocation is correct
Allocation per ASIN/Brand is blank or incorrect
Using Purchases[Brand] seems to block correct filter propagation
Question:
How should I correctly allocate Amazon Operating Expenses by ASIN and Brand, given the current model?
Do I need a proper Dim_ASIN dimension? Or is there a cleaner DAX solution without rebuilding the model?
Solved! Go to Solution.
Hi @akmughal,
The issue is that you are trying to allocate operating expenses by ASIN/Brand using purchase quantity as the allocation key but your denominator calculation is removing filters incorrectly, So let me tell you the Problem Analysis Then the Approach
Problem Analysis
First Approach: Clean DAX (Recommended)
Allocated Amazon Operating Expense :=
VAR CurrentAmazonExp = [Amazon Operating Expense] // This measure should filter for Operating Expenses
VAR CurrentDateContext = VALUES(DimDate[Date]) // Get current date context
// Calculate quantity for current context (ASIN, Brand, Date)
VAR ContextQty =
CALCULATE(
SUM(Purchases[Quantity]),
TREATAS(CurrentDateContext, Purchases[Date])
)
// Calculate total quantity for same date period
VAR TotalQty =
CALCULATE(
SUM(Purchases[Quantity]),
ALL(ASINMasterList),
ALLEXCEPT(Purchases, Purchases[Date]) // Keep date filter only
)
// Allocation formula
VAR AllocationRatio = DIVIDE(ContextQty, TotalQty, 0)
RETURN
IF(
NOT ISBLANK(CurrentAmazonExp) && TotalQty > 0,
CurrentAmazonExp * AllocationRatio,
BLANK()
)
Second Approach: Enhanced Model + DAX (Better For Long Term)
// Create a clean Dim_ASIN table
Dim_ASIN =
SUMMARIZE(
ASINMasterList,
ASINMasterList[ItemKey],
ASINMasterList[ASIN],
ASINMasterList[SKU],
ASINMasterList[Brand]
)Allocated Operating Expense v2 :=
VAR OperatingExpense =
CALCULATE(
SUM('FBA Revenue Report'[Amount]),
'FBA Revenue Report'[AccountType] = "Operating Expense"
)
VAR SelectedDates = VALUES(DimDate[Date])
// Quantity for current context (respects all filters)
VAR ContextQty =
CALCULATE(
SUM(Purchases[Quantity]),
TREATAS(SelectedDates, Purchases[Date])
)
// Total quantity for same dates, removing ASIN/Brand filters
VAR TotalQty =
CALCULATE(
SUM(Purchases[Quantity]),
TREATAS(SelectedDates, Purchases[Date]),
ALL(Dim_ASIN), // Remove ASIN filters
ALL(Dim_Brand) // Remove Brand filters
)
RETURN
DIVIDE(
OperatingExpense * ContextQty,
TotalQty,
BLANK()
)
Third Approach: Cross-Filtering (No Model Changes)
Allocated Expense CrossFilter :=
VAR OperatingExpense =
CALCULATE(
SUM('FBA Revenue Report'[Amount]),
'FBA Revenue Report'[AccountType] = "Operating Expense"
)
// Use TREATAS to bridge the gap between SKUs
VAR RelatedSKUs = VALUES(ASINMasterList[SKU])
VAR RelatedDates = VALUES(DimDate[Date])
// Calculate purchase quantity for related SKUs and dates
VAR ContextQty =
CALCULATE(
SUM(Purchases[Quantity]),
TREATAS(RelatedDates, Purchases[Date])
)
// Total quantity calculation
VAR TotalQty =
CALCULATE(
SUM(Purchases[Quantity]),
TREATAS(RelatedDates, Purchases[Date]),
ALL(ASINMasterList),
USERELATIONSHIP(Purchases[Brand], Brand[Brand]) // Explicitly use brand relationship
)
RETURN
IF(
NOT ISBLANK(OperatingExpense) && TotalQty > 0,
OperatingExpense * DIVIDE(ContextQty, TotalQty),
BLANK()
)Additional Helper Measures:
// Amazon Operating Expense (base measure)
Amazon Operating Expense :=
CALCULATE(
SUM('FBA Revenue Report'[Amount]),
'FBA Revenue Report'[AccountType] = "Operating Expense"
)
// Purchase Quantity (with proper context)
Purchase Quantity :=
SUM(Purchases[Quantity])
// Total Purchase Quantity (for allocation denominator)
Total Purchase Quantity :=
CALCULATE(
[Purchase Quantity],
ALL(ASINMasterList),
ALLEXCEPT(Purchases, Purchases[Date])
)
Final Note:
Hello @akmughal ,
You are allocation a fact by another fact. This is a really wrong approach. You need Dimension tables of Brand and ASIN. Because data modelling needs dimensions filtering facts not facts filtering themselves.
So how you can create dimensions?
1- Open power query.
2- Duplicate ASINMasterList and keep only ItemKey, ASIN, SKU, Brand.
3- Remove duplicates on ItemKey.
4- Rename Table DIM_ASIN
5- Duplicate ASINMasterList again.
6- Keep only brand.
7- Remove duplicates.
8- Rename DIM_Brand
We need to create correct relationships now.
Dim_ASIN[ItemKey] -> Purchases[Purchase_ItemKey] (1 -> many, single)
Dim_ASIN[SKU] -> FBA Revenue Report[SKU] (1 -> many, single)
Dim_Brand[Brand] -> Dim_ASIN[Brand] (1 -> many)
DimDate[Date] -> Purchases[Date]
DimDate[Date] -> FBA Revenue Report[Date]
These are the measures:
Amazon Operating Expense Amount=
CALCULATE (
SUM ( 'FBA Revenue Report'[Amount] ),
'FBA Revenue Report'[AccountType] = "Amazon Operating Expense"
)
Purchase Qty =
SUM ( Purchases[Quantity] )
Total Purchase Qty =
CALCULATE (
[Purchase Qty],
REMOVEFILTERS ( Dim_ASIN )
)
If this solved your issue, please mark it as the accepted solution. ✅
Hi akmughal,
We are following up to see if what we shared solved your issue. If you need more support, please reach out to the Microsoft Fabric community.
Thank you.
Thankyou, @Ahmed-Elfeel, @Jaywant-Thorat, @Kedar_Pande, @anilelmastasi and @Shubham_rai955 for your responses.
Hi akmughal,
We appreciate your inquiry through the Microsoft Fabric Community Forum.
We would like to inquire whether have you got the chance to check the solutions provided by @Ahmed-Elfeel, @Jaywant-Thorat, @Kedar_Pande, @anilelmastasi and @Shubham_rai955 to resolve the issue. We hope the information provided helps to clear the query. Should you have any further queries, kindly feel free to contact the Microsoft Fabric community.
Thank you.
The core issue is that the denominator is being calculated at the wrong grain and with the wrong filter removals, especially around Brand, so the ratio collapses or returns blanks at ASIN/Brand level even though the grand total happens to sum correctly.
Use Dim_ASIN (ASINMasterList) as the allocation dimension instead of Purchases[Brand] or other fact columns.
Compute the denominator as “total purchase quantity in the current Brand / date context, across all ASINs” using ALLEXCEPT or by clearing only the ASIN grain.
Avoid using a fact‑table attribute like Purchases[Brand] as the allocation dimension; let Brand come through the existing lookup or dimension.
Base measures (if you do not already have them):
Allocation measure at ASIN level, respecting Brand and Date context:
At row level (ASIN × Brand × Date), [Purchase Qty] gives that ASIN’s quantity.
TotalQtyInScope keeps Brand and Date filters but clears ASIN, so it becomes the total quantity for that Brand/date across all ASINs, which is the correct denominator.
The ratio ASINQty / TotalQtyInScope is then multiplied by the Brand/date‑level AmazonExp, so allocations roll up correctly and stay non‑blank at ASIN and Brand levels.
Yes, a proper Dim_ASIN (ASINMasterList) dimension is the right pattern and you already have it; use that as the row context in your visual and measures instead of Purchases[Brand].
With ASINMasterList connected to Purchases and Purchases carrying Brand via lookup, you get a clean star schema, and the DAX pattern above will allocate Opex correctly by ASIN and roll it up to Brand.
Hello @akmughal ,
You are allocation a fact by another fact. This is a really wrong approach. You need Dimension tables of Brand and ASIN. Because data modelling needs dimensions filtering facts not facts filtering themselves.
So how you can create dimensions?
1- Open power query.
2- Duplicate ASINMasterList and keep only ItemKey, ASIN, SKU, Brand.
3- Remove duplicates on ItemKey.
4- Rename Table DIM_ASIN
5- Duplicate ASINMasterList again.
6- Keep only brand.
7- Remove duplicates.
8- Rename DIM_Brand
We need to create correct relationships now.
Dim_ASIN[ItemKey] -> Purchases[Purchase_ItemKey] (1 -> many, single)
Dim_ASIN[SKU] -> FBA Revenue Report[SKU] (1 -> many, single)
Dim_Brand[Brand] -> Dim_ASIN[Brand] (1 -> many)
DimDate[Date] -> Purchases[Date]
DimDate[Date] -> FBA Revenue Report[Date]
These are the measures:
Amazon Operating Expense Amount=
CALCULATE (
SUM ( 'FBA Revenue Report'[Amount] ),
'FBA Revenue Report'[AccountType] = "Amazon Operating Expense"
)
Purchase Qty =
SUM ( Purchases[Quantity] )
Total Purchase Qty =
CALCULATE (
[Purchase Qty],
REMOVEFILTERS ( Dim_ASIN )
)
If this solved your issue, please mark it as the accepted solution. ✅
Allocated Amazon Expense =
VAR AmazonExp = [Amazon Operating Expense]
VAR ASINQty = SUM(Purchases[Quantity])
VAR TotalQty =
CALCULATE(
SUM(Purchases[Quantity]),
REMOVEFILTERS(Purchases[Purchase_ItemKey]),
KEEPFILTERS(Purchases[Brand])
)
RETURN
IF(TotalQty > 0, DIVIDE(ASINQty * AmazonExp, TotalQty), BLANK())
If this answer helped, please click Kudos or Accept as Solution.
-Kedar
LinkedIn: https://www.linkedin.com/in/kedar-pande
To @akmughal,
Excellent question, and this is a classic allocation + filter propagation problem in Power BI. You’re very close already; the issue is not your math, it’s filter context and model grain.
Why your current DAX is failing?
Root cause
Specifically:
you are:
Always remember: Never use a fact-table attribute as an allocation dimension
That’s exactly what’s happening with Purchases[Brand].
Correct allocation logic:
You want this logic:
Each ASIN gets a share of Amazon Opex proportional to its purchase quantity within the current Brand / Date context
Mathematically:
(ASIN Qty / Total Qty (same Brand + Date))*Amazon Operating Expense
So:
Your issue is that Brand context is not cleanly defined.
SOLUTION - Clean DAX Fix (No Model Rebuild)
This works with your current model, but fixes context handling.
Correct DAX Measure:
-----DAX-----
Allocated Amazon Operating Expense :=
VAR AmazonExp =
[Amazon Operating Expense]
VAR ASINQty =
SUM ( Purchases[Quantity] )
VAR BrandTotalQty =
CALCULATE (
SUM ( Purchases[Quantity] ),
ALLEXCEPT (
Purchases,
Purchases[Brand], -- keep Brand
DimDate[YearMonth] -- keep Date grain
)
)
RETURN
IF (
BrandTotalQty > 0,
DIVIDE ( ASINQty * AmazonExp, BrandTotalQty ),
BLANK ()
)
-----DAX-----
Why this works
Important:
=================================================
Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
Jaywant Thorat | MCT | Data Analytics Coach
LinkedIn: https://www.linkedin.com/in/jaywantthorat/
Join #MissionPowerBIBharat = https://shorturl.at/5ViW9
#MissionPowerBIBharat
LIVE with Jaywant Thorat from 15 Dec 2025
8 Days | 8 Sessions | 1 hr daily | 100% Free
Hi @akmughal,
The issue is that you are trying to allocate operating expenses by ASIN/Brand using purchase quantity as the allocation key but your denominator calculation is removing filters incorrectly, So let me tell you the Problem Analysis Then the Approach
Problem Analysis
First Approach: Clean DAX (Recommended)
Allocated Amazon Operating Expense :=
VAR CurrentAmazonExp = [Amazon Operating Expense] // This measure should filter for Operating Expenses
VAR CurrentDateContext = VALUES(DimDate[Date]) // Get current date context
// Calculate quantity for current context (ASIN, Brand, Date)
VAR ContextQty =
CALCULATE(
SUM(Purchases[Quantity]),
TREATAS(CurrentDateContext, Purchases[Date])
)
// Calculate total quantity for same date period
VAR TotalQty =
CALCULATE(
SUM(Purchases[Quantity]),
ALL(ASINMasterList),
ALLEXCEPT(Purchases, Purchases[Date]) // Keep date filter only
)
// Allocation formula
VAR AllocationRatio = DIVIDE(ContextQty, TotalQty, 0)
RETURN
IF(
NOT ISBLANK(CurrentAmazonExp) && TotalQty > 0,
CurrentAmazonExp * AllocationRatio,
BLANK()
)
Second Approach: Enhanced Model + DAX (Better For Long Term)
// Create a clean Dim_ASIN table
Dim_ASIN =
SUMMARIZE(
ASINMasterList,
ASINMasterList[ItemKey],
ASINMasterList[ASIN],
ASINMasterList[SKU],
ASINMasterList[Brand]
)Allocated Operating Expense v2 :=
VAR OperatingExpense =
CALCULATE(
SUM('FBA Revenue Report'[Amount]),
'FBA Revenue Report'[AccountType] = "Operating Expense"
)
VAR SelectedDates = VALUES(DimDate[Date])
// Quantity for current context (respects all filters)
VAR ContextQty =
CALCULATE(
SUM(Purchases[Quantity]),
TREATAS(SelectedDates, Purchases[Date])
)
// Total quantity for same dates, removing ASIN/Brand filters
VAR TotalQty =
CALCULATE(
SUM(Purchases[Quantity]),
TREATAS(SelectedDates, Purchases[Date]),
ALL(Dim_ASIN), // Remove ASIN filters
ALL(Dim_Brand) // Remove Brand filters
)
RETURN
DIVIDE(
OperatingExpense * ContextQty,
TotalQty,
BLANK()
)
Third Approach: Cross-Filtering (No Model Changes)
Allocated Expense CrossFilter :=
VAR OperatingExpense =
CALCULATE(
SUM('FBA Revenue Report'[Amount]),
'FBA Revenue Report'[AccountType] = "Operating Expense"
)
// Use TREATAS to bridge the gap between SKUs
VAR RelatedSKUs = VALUES(ASINMasterList[SKU])
VAR RelatedDates = VALUES(DimDate[Date])
// Calculate purchase quantity for related SKUs and dates
VAR ContextQty =
CALCULATE(
SUM(Purchases[Quantity]),
TREATAS(RelatedDates, Purchases[Date])
)
// Total quantity calculation
VAR TotalQty =
CALCULATE(
SUM(Purchases[Quantity]),
TREATAS(RelatedDates, Purchases[Date]),
ALL(ASINMasterList),
USERELATIONSHIP(Purchases[Brand], Brand[Brand]) // Explicitly use brand relationship
)
RETURN
IF(
NOT ISBLANK(OperatingExpense) && TotalQty > 0,
OperatingExpense * DIVIDE(ContextQty, TotalQty),
BLANK()
)Additional Helper Measures:
// Amazon Operating Expense (base measure)
Amazon Operating Expense :=
CALCULATE(
SUM('FBA Revenue Report'[Amount]),
'FBA Revenue Report'[AccountType] = "Operating Expense"
)
// Purchase Quantity (with proper context)
Purchase Quantity :=
SUM(Purchases[Quantity])
// Total Purchase Quantity (for allocation denominator)
Total Purchase Quantity :=
CALCULATE(
[Purchase Quantity],
ALL(ASINMasterList),
ALLEXCEPT(Purchases, Purchases[Date])
)
Final Note:
| User | Count |
|---|---|
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 |
| User | Count |
|---|---|
| 16 | |
| 12 | |
| 8 | |
| 8 | |
| 7 |