Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
akmughal
New Member

DAX allocation of Amazon Operating Expenses by ASIN and Brand — denominator not splitting correctly

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:

  1. 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:

              Allocated Amazon Operating Expense := VAR AmazonExp = [Amazon Operating Expense] VAR ASINQty = SUM(Purchases[Quantity]) VAR TotalQty = CALCULATE( SUM(Purchases[Quantity]), REMOVEFILTERS(Purchases[Brand_Purchases.lookupValue]), REMOVEFILTERS(Purchases[Purchase_ItemKey]) ) RETURN IF(TotalQty > 0, DIVIDE(ASINQty * AmazonExp, TotalQty), BLANK())
               

              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?

2 ACCEPTED SOLUTIONS
Ahmed-Elfeel
Solution Sage
Solution Sage

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

  • You dont have a direct relationship between the FBA Revenue Report and ASIN/Brand tables
  • The REMOVEFILTERS approach is too aggressive and removes necessary filters
  • Using a lookup value from Brand table without proper relationships causes issues

First Approach: Clean DAX (Recommended)

  • Create this allocation measure:
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)

  • First Create Proper Dimension Tables (Dim_ASIN table):
// Create a clean Dim_ASIN table
Dim_ASIN = 
SUMMARIZE(
    ASINMasterList,
    ASINMasterList[ItemKey],
    ASINMasterList[ASIN],
    ASINMasterList[SKU],
    ASINMasterList[Brand]
)
  • Second Create Relationships:
    • Dim_ASIN[ItemKey] → Purchases[Purchase_ItemKey] (1:*, Active)
    • Dim_Date[Date] → Purchases[Date] (1:*, Active)
    • Dim_Date[Date] → 'FBA Revenue Report'[Date] (1:*, Inactive)
    • Create a separate Dim_Brand table with proper relationships
  • Finally Enhanced Allocation Measure
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) 

  • If you won't/can't modify the model use this approach:
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:

  • The Second Approach (enhanced model) will give you the best performance and maintainability, but the   First Approach should work with your current model after adjusting the denominator calculation
if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.

View solution in original post

anilelmastasi
Super User
Super User

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.

View solution in original post

7 REPLIES 7
v-pnaroju-msft
Community Support
Community Support

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.

v-pnaroju-msft
Community Support
Community Support

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.

Shubham_rai955
Memorable Member
Memorable Member

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.

Key changes to the logic

  • 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.

Suggested measures

Base measures (if you do not already have them):

 
text
Amazon Operating Expense := CALCULATE ( SUM ( 'FBA Revenue Report'[Amount] ), 'FBA Revenue Report'[AccountType] = "Amazon Operating Expense" ) Purchase Qty := SUM ( Purchases[Quantity] )

Allocation measure at ASIN level, respecting Brand and Date context:

 
Allocated Amazon Operating Expense := VAR AmazonExp = [Amazon Operating Expense] VAR ASINQty = [Purchase Qty] VAR TotalQtyInScope = CALCULATE ( [Purchase Qty], ALL ( ASINMasterList ), -- remove ASIN/ItemKey grain ALLEXCEPT ( Purchases, Purchases[Brand], -- keep Brand in context DimDate[YearMonth] -- or DimDate[Date] / other date grain you use in the visual ) ) RETURN IF ( NOT ISBLANK ( AmazonExp ) && TotalQtyInScope > 0, AmazonExp * DIVIDE ( ASINQty, TotalQtyInScope ), BLANK () )
  • 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.

On the Dim_ASIN question

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.

anilelmastasi
Super User
Super User

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.

Kedar_Pande
Super User
Super User

@akmughal 

 

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

Jaywant-Thorat
Resolver IV
Resolver IV

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

  • You are allocating a fact-table measure (Amazon Opex)
  • using another fact-table (Purchases)
  • without a shared conformed dimension at the correct grain.

Specifically:

  • Purchases[Brand] is a lookup-derived column
  • It is not a real dimension
  • When you do DAX:
    • REMOVEFILTERS(Purchases[Brand])

you are:

  • Breaking the natural filter context
  • Preventing ASIN / Brand from resolving correctly
  • Causing blank or incorrect allocations at lower grain

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:

  • Numerator → ASIN-level quantity
  • Denominator → Total quantity at Brand level (not ASIN)

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.

  • Do NOT remove filters blindly
  • Keep Brand context
  • Remove only ASIN granularity

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

  • ALLEXCEPT:
    • Removes ASIN filter
    • Preserves Brand + Date
  • Allocation denominator is now correctly scoped
  • Totals reconcile perfectly
  • ASIN & Brand visuals both behave correctly

Important:

  • Use Brand from Purchases ONLY for now
  • Do not mix Brand from another table in visuals

=================================================
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

Ahmed-Elfeel
Solution Sage
Solution Sage

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

  • You dont have a direct relationship between the FBA Revenue Report and ASIN/Brand tables
  • The REMOVEFILTERS approach is too aggressive and removes necessary filters
  • Using a lookup value from Brand table without proper relationships causes issues

First Approach: Clean DAX (Recommended)

  • Create this allocation measure:
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)

  • First Create Proper Dimension Tables (Dim_ASIN table):
// Create a clean Dim_ASIN table
Dim_ASIN = 
SUMMARIZE(
    ASINMasterList,
    ASINMasterList[ItemKey],
    ASINMasterList[ASIN],
    ASINMasterList[SKU],
    ASINMasterList[Brand]
)
  • Second Create Relationships:
    • Dim_ASIN[ItemKey] → Purchases[Purchase_ItemKey] (1:*, Active)
    • Dim_Date[Date] → Purchases[Date] (1:*, Active)
    • Dim_Date[Date] → 'FBA Revenue Report'[Date] (1:*, Inactive)
    • Create a separate Dim_Brand table with proper relationships
  • Finally Enhanced Allocation Measure
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) 

  • If you won't/can't modify the model use this approach:
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:

  • The Second Approach (enhanced model) will give you the best performance and maintainability, but the   First Approach should work with your current model after adjusting the denominator calculation
if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.