I need to calculate the variation of sales volume of the current month vs the same period of the previous year.
At a product level the formula is working fine, but the subtotals and totals DO NOT ADD UP.
I have tried many approaches and techniques available on the web, but I couldn't find anything related to calculating a measure using data from different periods.
The formula basically is:
[ (Sales Qty 2016) - (Sales Qty 2015) ] * [ (Sales Amount 2015) / (Sales Qty 2015) ]
My DAX formula attempt is:
=(CALCULATE(sumx(Sales_Data,Sales_Data[Qty]))- ****Sales Qty 2016******
CALCULATE(sumx(Sales_Data,Sales_Data[Qty]),SAMEPERIODLASTYEAR(Date_Table[DateKey])))* ****Sales Qty 2015******
(CALCULATE(sumx(Sales_Data,Sales_Data[Net Sales Inc.Rebate]),SAMEPERIODLASTYEAR(Date_Table[DateKey])) / ******Sales Amount 2015******
CALCULATE(sumx(Sales_Data,Sales_Data[Qty]),SAMEPERIODLASTYEAR(Date_Table[DateKey]))) ****Sales Qty 2015******
Any way that I can calculate the subtotal and totals a per the table below.
[TABLE="width: 515"]
<colgroup><col span="5"></colgroup><tbody>[TR]
[TD][/TD]
[TD]Qty 2016[/TD]
[TD]Qty 2015[/TD]
[TD]ASP 2015[/TD]
[TD]Var Vol[/TD]
[/TR]
[TR]
[TD]Product A[/TD]
[TD="align: right"]494[/TD]
[TD="align: right"]1,031[/TD]
[TD="align: right"]$142.11[/TD]
[TD="align: right"]-76,315[/TD]
[/TR]
[TR]
[TD]Product B[/TD]
[TD="align: right"]10,888[/TD]
[TD="align: right"]7,706[/TD]
[TD="align: right"]$428.29[/TD]
[TD="align: right"]1,362,814[/TD]
[/TR]
[TR]
[TD]Product C[/TD]
[TD="align: right"]331[/TD]
[TD="align: right"]1,218[/TD]
[TD="align: right"]$215.85[/TD]
[TD="align: right"]-191,462[/TD]
[/TR]
[TR]
[TD]TOTAL[/TD]
[TD="align: right"]11,720[/TD]
[TD="align: right"]9,961[/TD]
[TD="align: right"]$372.43[/TD]
[TD="align: right"]655,112[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD="colspan: 2"]Should be this total-->[/TD]
[TD="align: right"]1,095,037[/TD]
[/TR]
</tbody>[/TABLE]
Many thanks.
Favio
At a product level the formula is working fine, but the subtotals and totals DO NOT ADD UP.
I have tried many approaches and techniques available on the web, but I couldn't find anything related to calculating a measure using data from different periods.
The formula basically is:
[ (Sales Qty 2016) - (Sales Qty 2015) ] * [ (Sales Amount 2015) / (Sales Qty 2015) ]
My DAX formula attempt is:
=(CALCULATE(sumx(Sales_Data,Sales_Data[Qty]))- ****Sales Qty 2016******
CALCULATE(sumx(Sales_Data,Sales_Data[Qty]),SAMEPERIODLASTYEAR(Date_Table[DateKey])))* ****Sales Qty 2015******
(CALCULATE(sumx(Sales_Data,Sales_Data[Net Sales Inc.Rebate]),SAMEPERIODLASTYEAR(Date_Table[DateKey])) / ******Sales Amount 2015******
CALCULATE(sumx(Sales_Data,Sales_Data[Qty]),SAMEPERIODLASTYEAR(Date_Table[DateKey]))) ****Sales Qty 2015******
Any way that I can calculate the subtotal and totals a per the table below.
[TABLE="width: 515"]
<colgroup><col span="5"></colgroup><tbody>[TR]
[TD][/TD]
[TD]Qty 2016[/TD]
[TD]Qty 2015[/TD]
[TD]ASP 2015[/TD]
[TD]Var Vol[/TD]
[/TR]
[TR]
[TD]Product A[/TD]
[TD="align: right"]494[/TD]
[TD="align: right"]1,031[/TD]
[TD="align: right"]$142.11[/TD]
[TD="align: right"]-76,315[/TD]
[/TR]
[TR]
[TD]Product B[/TD]
[TD="align: right"]10,888[/TD]
[TD="align: right"]7,706[/TD]
[TD="align: right"]$428.29[/TD]
[TD="align: right"]1,362,814[/TD]
[/TR]
[TR]
[TD]Product C[/TD]
[TD="align: right"]331[/TD]
[TD="align: right"]1,218[/TD]
[TD="align: right"]$215.85[/TD]
[TD="align: right"]-191,462[/TD]
[/TR]
[TR]
[TD]TOTAL[/TD]
[TD="align: right"]11,720[/TD]
[TD="align: right"]9,961[/TD]
[TD="align: right"]$372.43[/TD]
[TD="align: right"]655,112[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD="colspan: 2"]Should be this total-->[/TD]
[TD="align: right"]1,095,037[/TD]
[/TR]
</tbody>[/TABLE]
Many thanks.
Favio