Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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, %change shows the Total sales change back to that date selection.
I am trying many options on the internet but all options are shows Year over year %change and that logic is not applicable here.
So please help me out.
Thanks
Solved! Go to Solution.
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.
To calculate a change in % you need two time periods to compare. In the slicer you select one time period, what do you want to compare it to? The total sales of all time? A "trick" when comparing time periods is to connect two date dimensions with inactive relations. Add two slicers to the report (using the two date tables). Then you create a few measures, something like this:
SalesPeriod1 = CALCULATE(SUM('Sales'[Amount]), USERELATIONSHIP('Sales'[Date], Date1[Date]))
SalesPeriod2 = CALCULATE(SUM('Sales'[Amount]), USERELATIONSHIP('Sales'[Date], Date2[Date]))
Change = [SalesPeriod2]-[SalesPeriod1]
Change % = DIVIDE(Change, SalesPeriod1)
Hi @Anonymous,
Thank you for quick response and time.
I need to compare the period selected in the current slicers with the same last period back to that selected period.
In the below image, you can see the relative date slicer, in which we select
last 1 week, so %change is for the selected week and one week back of the selected week, same as if we select
last 1 month, so it displays %change for selected month and last one month back and so on
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
10 | |
7 | |
6 | |
6 |
User | Count |
---|---|
17 | |
14 | |
11 | |
9 | |
7 |