Forum Discussion
Calculate %Change
- Anonymous6 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.
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.
Anonymous,
Thank You so much for the Solution, It seems Working.
Thank you for your precious time.