Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Need Help Dax Measure Not Returning Correct Result

I have a DAX measure where I am trying to calculate Sales Volume by Channel. The Delivery channel includes Food Aggregator Sales. I need to be able to subtract Food Aggregator Sales from the Delivery Sales to get the actual amount of non-food aggregator delivery sales. 

 

Here is an actual example. In the image below for store 1513 in the month of January 2022 Delivery sales show 5,425,209 and food aggregator sales totaling  2,719,837. Essentially, what should happen is I need to subtract food aggregator sales from the delivery sales which would leave a delivery sales total of 2,705,372. As shown in the screenshot below, that is not happening.

Here is my DAX code. I cannot identify why FoodAggregatorSales is not being subtracted from DeliverySales. I also created a stand-alone measure that calculates food aggregator sales to see if that would solve it, but using that measure to subtract from DeliverySales still does not work. Any guidance on what i'm doing wrong?

Sales Volume =

var FoodAggregatorSales = CALCULATE(
        SUMX(FILTER('Sales Detail', [Measure Type] = "Sales Volume" && 'Sales Detail'[Channel] = "Food Aggregator"), 'Sales Detail'[Volume])
)

var DeliverySales = CALCULATE(
        SUMX(FILTER('Sales Detail', [Measure Type] = "Sales Volume" && 'Sales Detail'[Channel] = "Delivery"), 'Sales Detail'[Volume]) - FoodAggregatorSales
)

var TakeAwaySales = CALCULATE(
        SUMX(FILTER('Sales Detail', [Measure Type] = "Sales Volume" && 'Sales Detail'[Channel] = "Take Away"), 'Sales Detail'[Volume])
)


var TotalSales =

SWITCH(
    SELECTEDVALUE('Sales Detail'[Channel]),
    "Delivery",
    DeliverySales,
    "Take Away",
    TakeAwaySales,
    "Food Aggregator",
    FoodAggregatorSales,
    DeliverySales + FoodAggregatorSales + TakeAwaySales
)

RETURN TotalSales
  • Anonymous's avatar
    Anonymous
    2 years ago

    Solved my issue. I was missing an ALL function in my FoodAggregatorSales variable that was returning 0. THis is Fixed.

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Solved my issue. I was missing an ALL function in my FoodAggregatorSales variable that was returning 0. THis is Fixed.