Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Calculate %Change

Hi All,   I am trying to calculate Total Sales %change over time selected by Date slicer. The following image shows the details of the problem. On selection of particular date in date slicers, %c...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Ok, I understand. If you always want to have the same number of dates in the previous period you could do something like this. But if you for example select a month with 31 days it will compare to the previous 31 days, not the previous month.

     

    SalesSelectedPeriod = SUM(Sales[TotalSales])

    SalesPreviousPeriod = CALCULATE(SUM(Sales[TotalSales]), FILTER(ALL(Sales[Date]), Sales[Date]<MIN(Sales[Date]) && Sales[Date]>=MIN(Sales[Date])-COUNT(Sales[Date])))

    Change = Sales[SalesSelectedPeriod] - Sales[SalesPreviousPeriod]

    Change % = DIVIDE([Change]; [SalesPreviousPeriod])

     

    There might be problems if you don't have sales every day. In that case you should use a date dimension that has all dates, even days without sales.